HTTPThe development (World Wide Web Consortium) AndInternetTeam (Internet Engineering Task Force) Cooperation results, (they) finally released a seriesRFC, The most famous of which isRFC 2616.RFC 2616DefinedHTTPA common version of the protocol --HTTP 1.1.
HTTPIs a protocol used for requests and responses between the client and the server. OneHTTPClient, such asWebBrowser, by creating a special port to the remote host (the default port is80) To initiate a request. OneHTTPThe server waits for the client to send a request sequence by listening to a special port, Like"Get, HTTP, 1.1"(Used to request the default page of the Web server), with a selected receiving imageEmailSameMimeMessage, which contains a large number of information headers used to describe all aspects of the request and respond to a selected retained data subject. After receiving a request sequence (if there is still a message), the server will send back a response, such as"200 OKAnd send back a message from this newspaper. The message body may be the requested file, error message, or other information.
HTTPA Message consists of a request from the client to the server and a response from the server to the client. The Request Message format is as follows:
Request Line -- Common Information header -- Request Header -- entity header -- Message Body
The request line starts with a method field, followedURLFields andHTTPProtocol version field, andCRLFEnd.SPIs a separator. ExceptCRLFIn sequenceCfAndLfIs required. For details about common information headers, request headers and object headers, refer to relevant documents.
The format of the response message is as follows:
Status line -- Common Information header -- Response Header -- entity header -- Message Body
Status Code3It indicates whether the request is understood or satisfied. The Reason Analysis briefly describes the status code of the original text. The status code is used to support automatic operations, and the cause analysis is used for users. The client does not need to check or display the syntax. For details about the common information headers, the response headers and object headers, refer to relevant documents.
HTTP/1.1The Protocol defines eight methods to indicate the actions required for the execution of confirmed resources:
LOptions-- ReturnHTTPRequest method, which can be used to check the functions of the network server.
LHead-- Ask for andGetThe response body will not be returned. This method can obtain metadata contained in the Response Message Header without transmitting the entire response content.
LGet-- Send a request to a specific resource.GetMethods should not be used in operations that produce side effects.
LPost-- Submit data to a specified resource for processing. Data is contained in the request body,PostThe request may result in the creation and/Or modify existing resources.
LPut-- Upload the latest content to the specified resource location.
LDelete-- Delete a specified resource.
LTrace-- Echo the request received by the server.
LConnect--HTTP/1.1The Protocol is reserved for proxy servers that can change connections to pipelines.
AllHTTPThe first line of the response is the status line.,Is the currentHTTPVersion number,3Status composed of digitsCodeAnd phrases that describe the status. They are separated by spaces. The first number of the status code indicates the type of the current response:
L1xxMessage-the request has been received by the server and continues Processing
L2XXSuccess-the request has been successfully received, understood, and accepted by the server
L3xxRedirection -- this request can be completed only after subsequent operations
L4xxRequest error -- The request contains a lexical error or cannot be executed
L5xxServer Error -- an error occurs when the server processes a correct request.
CommonHTTPStatus Code:
L200 OK--
L302 found--
L304 not modified--
L401 unauthorized--
L403 Forbidden--
L404 not found--
L500 Internal Server Error--
Common Response Headers:
Server--WebThe name and version of the server.
Date-- Current date (Greenwich Mean Time ).
Last-modified-- Date of the last modified document.
Expires-- The expiration date of the document.
Content-Length-- The length of the attached data (in bytes ).
Content-Type--MimeType.
WWW-Authenticate-- Used for verification. The content tells the client what authentication information (such as the user name and password) The software must provide ).