Something about HTTP Protocol

来源:互联网 发布:大麻淘宝 编辑:程序博客网 时间:2024/05/21 18:48

0. An HTTP request consists of three components:
* Method—–URI—Protocol/Version
* Request headers
* Entity body
An example of an HTTP request is the following:

POST /servlet/default.jsp HTTP/1.1
Accept: text/plain; text/html
© Budi Kurniawan 2003 2
Accept-Language: en-gb
Connection: Keep-Alive
Host: localhost
Referer: http://localhost/ch8/SendDetails.htm
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
LastName=Franks&FirstName=Michael


1. Replacing HTTP/1.0 is the current version of HTTP/1.1, which is defined by RFC 2616 and downloadable from http://www.w3.org/Protocols/HTTP/1.1/rfc2616.pdf


2. HTTP Requests:

The method—URI—protocol version appears as the first line of the request.

A URL is actually a type of URI (see http://www.ietf.org/rfc/rfc2396.txt).

URI 是从虚拟根路径开始的URL是整个链接如URL http://zhidao.baidu.com/question/68016373.html  URI 是/question/68016373.html百度服务器把http://zhidao.baidu.com/制作成了虚拟的路径的根
3. Between the headers and the entity body, there is a blank line (CRLF) that isimportant to the HTTP request format. The CRLF tells the HTTP server where the entitybody begins. In some Internet programming books, this CRLF is considered the fourthcomponent of an HTTP request.
CRLF is carriage return/linefeed
4.Similar to requests, an HTTP response also consists of three parts:
* Protocol—Status code–—Description* Response headers* Entity bodyThe following is an example of an HTTP response:
HTTP/1.1 200 OKServer: Microsoft-IIS/4.0Date: Mon, 3 Jan 1998 13:13:33 GMTContent-Type: text/htmlLast-Modified: Mon, 11 Jan 1998 13:23:42 GMTContent-Length: 112<HTML><HEAD><TITLE>HTTP Response Example</TITLE></HEAD><BODY>Welcome to Brainy Software</BODY></HTML>

0 0
原创粉丝点击