PrefaceReview the knowledge of the computer network and record
BodyDefinition: The HTTP protocol (hypertext Transfer Protocol, Hypertext Transfer Protocol) is the transfer protocol used to transmit hypertext to the local browser from the WWW server.
I. HTTP request process (non-persistent connection)The process of accessing the URL: (Take Http://www.someSchool.edu/department/home.index as an example) the 1.HTTP client process initiates a TCP link to the server (three handshake) at port number 80, which is associated with the connection on the client and the server, respectively. 2.HTTP sends an HTTP request message to the server via its socket, and the request packet contains the path name/department/home.index. The 3.HTTP server process accepts the request message through its sockets, retrieves the object www.someSchool.edu/department/home.index from its memory, encapsulates the object in an HTTP response message, and sends a response message to the server via a socket. 4. The server process notifies TCP to disconnect the TCP connection (but until TCP confirms that the client has received a response message intact, it will actually interrupt the connection, that is, four breakup processes) 5. The HTTP client receives the response message and the TCP connection is closed. If there are references to other files, repeat the first 4 steps.
second, the HTTP message format
1.HTTP Request Message
Get/somedir/page.html HTTP/1.1HOST:WWW.SOMESCHOOL.EDUCONNECTION:CLOSEUSER-AGENT:MOZILLA/5.0ACCEPT-LANGUAGE:FR
1) The first line is the request line, which contains the requested method, URL field, HTTP version field 2) after the call header line. Host domain name, connection is the connection method (close short connection/keep-alive long connection), user-agent for the user agent, that is, send the request to the server type of browser, Accpet--language is the language. 3) If it is post, the header line is followed by a blank line, followed by the body content (the form, and so on). 4) Get is usually used to request an object to the server, head is similar to get, except that the server receives a head request with only one HTTP message response, does not return objects, commonly used to track debugging. Put is used in conjunction with the Web Publishing tool to allow users to upload objects to the specified path on the specified Web server. Delete allows the user to delete objects on the Web server.
2.HTTP Response Message
http/1.1 okconnection:closedate:tue,09 15:44:04 gmtserver:apache/2.2.3 (Centos) last-modified:tue,09 15:11:03 gmtcontent-length:6821content-type:text/html (Data ... data )
It is divided into three parts: the initial state line, the 6 first row, the entity row.
Initial status line: Contains protocol version, status code, and corresponding status information.
Header Line: Connection connection method, date indicates the datetime that the server generated and sent the response message, the server server type, last-modified represents the date time that the object was created or last modified, typically used to compare the time of the cache update ; content-length indicates the number of bytes of the object being sent; Content-type represents the object type format.
Entity Content: The entity of the response message above is HTML text
Return code:
- OK: The request was successful.
- 301 Move Permanently: The requested object has been permanently transferred, and the new URL is defined in the location header row of the response message.
- The bad request: a generic error code that indicates that the requesting server is not understood.
- 404 Not Found: The requested resource does not exist.
- 5XX: Problems with the server.
3.CookieUsed to identify a user and to save some user information. There are 4 components of cookie technology:
- A cookie in the HTTP response message header line: Set-cookie (the server returns a new client if no cookie or cookie expires when the connection is first established).
- A cookie in the HTTP request message header line: cookie.
- A cookie that is retained in the client system and managed by the user's browser.
- Cookies located in the backend database of the Web site
4. SupplementThe URI full name is uniform Resource indentifier (Uniform Resource ID), used to uniquely identify a resource, is a generic concept, URI consists of two major subset URLs and urns that make up the URL full name is uniform Resource Locator (Uniform Resource positioning), which identifies the resource urn by its location to identify the full name of uniform Resource name (Uniform Resource naming), identifies the resource by its name, regardless of where it is located, so that its urn does not change even if the location of the resource is changed
References" computer network Top-down method 6th Edition" mechanical Industry Press "Beauty" James F.kurose & Keith W.ross
Computer network Related: Application layer Protocol (ii): HTTP