ITeye博客

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

tobylxy · 2012-11-30 17:25 · Web · 互联网 · Markdown

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

<html>
<head>
<title>HTTP Response Example</title>
</head>
<body>
Welcome to Brainy Software
</body>
</html>
------------------------------------------------

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。