The second chapter of the HTTP protocol

The second chapter of the HTTP protocol

Explain the structure for the HTTP protocol

1. by exchanging requests and responses to achieve the purpose of the communication

  HTTP protocol application, must be the end of the client role, and the other end as the server role.

  [ Request packet ] is a request method, URI of the, protocol version, request header fields, the content of entities.

 

 

  [ Response packet ] is a protocol version, status code, status code reason phrase, response header field, the response of entities.

 

2.HTTP is a protocol (Stateless) does not save state

   HTTP is a non-save state, ie stateless protocol. HTTP protocol itself does not request and the communication status between the response stored. In other words HTTP this level, it sent a request for agreement or do not respond to treatment persistence. This is for faster processing large number of transactions, to ensure that the agreement scalability.

 

3. Method Request

 

[ GET ] access to resources

 

 

[ POST ] transmission entity body, although similar role POST and GET, POST but the main purpose is not to obtain the response of the subject matter, but to deliver content to the server.

 

 

[ PUT ] file transfer: Requires the request body contains the file contents.

 

[ HEAD ] get the message header: HEAD GET method and the same method, but does not return a message body part. Date and time for confirming the validity of the updated resource URI and so on.

DELETE】删除文件

OPTIONS】询问支持的方法:用来查询针对请求URI指定的资源支持的方法。

TRACE】追踪路径:让Web服务端将之前的请求通信还会给客户端。

CONNECT】要求用隧道协议连接代理:主要使用SSL和TLS协议把通信内容加密后经网络隧道传输。

 4.持久连接节省通信量

  持久连接特点:只要任意一端没有明确提出断开连接,则保持TCP连接状态。称为keep-alive或者connection reuse。目的是为了建立一次TCP连接后进行多次请求和响应的交互。HTTP/1.1中所有的连接默认是持久连接,但在HTTP/1.0未标准化。

  【管线化】从前发送请求后需要收到响应,才能发送下一个请求。管线化技术出现后,不用等待响应就可以直接发送下一个请求。这样就可以实现并行发送多个请求。

 

5.使用Cookie的状态管理  

  HTTP 是无状态协议,它不对之前发生过的请求和响应的状态进行管理。也就是说,无法根据之前的状态进行本次的请求处理。所以引入Cookie技术,Cookie技术通过在请求和响应报文中写入Cookie信息来控制客户端状态。

  Cookie 会根据从服务器端发送的响应报文内的个叫做 Set-Cookie 首部字段信息,通知客户端保存 Cookie当下次客户端再往该服务器发送请求时,客户端会自动在请求报文中加入 Cookie 值后发送出去。

  服务器端发现客户端发送过来的 Cookie 后,会去检查究竟是从哪个客户端发来的连接请求,然后对比服务器上的记录,最后得到之前的状态信息。

Guess you like

Origin www.cnblogs.com/qmillet/p/12075365.html