您的位置:首页 > 理论基础 > 计算机网络

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

2015-05-12 13:43 369 查看
转自: http://tobylxy.iteye.com/blog/1739125
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>

------------------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: