Application Layer - HTTP

 

1.HTTP: Hypertext Communication Protocol.

2. Stateless, short connection.

    A connection channel with the server is established based on TCP, a new connection is created for each request, and it is closed after the end without retaining any state. But since HTTP/1.1, Keep-Alive is enabled by default to keep the connection feature

    ( TCP protocol - transport layer, HTTP protocol - application layer ) ( TCP protocol - road, communication, HTTP protocol - car, encapsulated data )

3. HTTP request format: Line--Header--Body ( see the above link for the meaning of each header attribute )

    "GET" method, the body is empty

4. HTTP response format: Line--Header--Body ( see the above link for the meaning of each attribute of the header )

 

 5. http defines methods for interacting with the server:

       GET, POST, PUT, DELETE correspond to the four operations of checking, modifying, adding and deleting.

 

7. HTTP response status code:

1XX prompt message - Indicates that the request has been successfully received, continue processing

2XX Success - Indicates that the request has been successfully received, understood, accepted ------ 200 Success

3XX redirects - further processing is required to complete the request

------302 Found redirection, prompting the browser to re-initiate the request using the URL of the Location in the Response.

------304 Not Modified Use the last cached document. If you don't want to use the local cache, you can use Ctrl+F5 to force refresh the page.

4XX Client Error - The request has a syntax error or the request cannot be fulfilled

------400 Bad Request Client request and syntax error, cannot be understood by the server

------403 Forbidden The server received the request, but refused to provide service

------404 Not Found

5XX Server Side Error - The server failed to fulfill a legitimate request

------500 Internal Server Error An unexpected error occurred on the server

------503 Server Unavailable The server is currently unable to process the client's request and may return to normal after a period of time

 

6. Content-Type:

text/html; charset=utf-8: html document

text/plain: plain text

application/json: JSON object (backend @RequestBody)

application/x-www-form-urlencoded: key-value pair mode, form submission format (background @RequestParam)

application/octet-stream, multipart/form-data : file, image (download), stream mode (background @RequestParam)

image/jpeg, image/png: image (display)

8. Interaction between local cookie and server:  

              Request : The Cookie is passed to the server in the HTTP Request Header, and the server can take the value request.getCookies();

              Response: Server Response.addcookie(xxx), HTTP Response Header will generate Set-Cookie, used to send cookie to client browser,

                                Each write cookie will generate a Set-Cookie

                                例如: Set-Cookie: sc=4c31523a; path=/; domain=.acookie.taobao.com

              JS can also manipulate cookies.

 

9. The difference between HTTP protocol is stateless and Connection: keep-alive

Stateless means that the protocol has no memory for transaction processing, and the server does not know what state the client is. On the other hand, there is no connection between opening a page on a server and opening a page on that server before you

HTTP is a stateless connection-oriented protocol. Statelessness does not mean that HTTP cannot maintain a TCP connection, nor does it mean that HTTP uses the UDP protocol (no connection).

Since HTTP/1.1, Keep-Alive is enabled by default to keep the connection feature. Simply put, when a web page is opened, the TCP connection between the client and the server for transmitting HTTP data will not be closed. If the client Visiting the web page on this server again will continue to use this established connection

 Keep-Alive does not keep the connection forever, it has a keep time, which can be set in different server software (such as Apache)

 http://www.cnblogs.com/TankXiao/archive/2012/02/13/2342672.html#httpmeessagestructe

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325445944&siteId=291194637