HTTP Request / Response 报文基本信息结构

About HTTP Request/Response

Request:
An HTTP request consists of three components:
Method—Uniform Resource Identifier (URI)—Protocol/Version
Request headers
Entity body


An example of an HTTP request is the following:
-----------------------------------------------

POST /examples/default.jsp HTTP/1.1   --(URI)—Protocol/Version
                          
Accept: text/plain; text/html         --Request Header     
Accept-Language: en-gb
Connection: Keep-Alive
Host: localhost
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
Content-Length: 33
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
                                      --There is a blank line(CRLF)
lastName=Franks&firstName=Michael     --Entity Body
-------------------------------------------------
comment:
The CRLF:carriage return/line feed tells the HTTP server whrer the entity body begins.

Response:
An HTTP request consists of three components:
Protocol—Status code—Description
Response headers
Entity body


An example of an HTTP response is the following:
-----------------------------------------------

HTTP/1.1 200 OK
Server: Microsoft-IIS/4.0
Date: Mon, 5 Jan 2004 13:13:33 GMT
Content-Type: text/html
Last-Modified: Mon, 5 Jan 2004 13:13:12 GMT
Content-Length: 112



HTTP Response Example


Welcome to Brainy Software


------------------------------------------------

 

你可能感兴趣的:(Web)