HTTP请求包括三部分:请求行(Request Line),头部(Headers)和数据体(Body)。其中,请求行由请求方法(method),请求网址Request-URI和协议 (Protocol)构成,而请求头包括多个属性,数据体则可以被认为是附加在请求之后的文本或二进制文件。
下面例子显示HTTP请求GET方式的报文内容:
GET /qingdao.html HTTP/1.1 Accept:text/html, */*
Accept-Language:zh-cn
Referer: http://10.5.13.21/upload
User-Agent:Mozilla/4.0(compatible;MSIE 5.01;Windows NT 5.0;DigExt)
Accept-Encoding:gzip,deflate
Host: 10.5.13.21
Connection:Keep-Alive
下面例子显示HTTP请求POST方式的报文内容:
POST /upload/ HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://10.5.13.21/upload/
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
Content-Type: multipart/form-data; boundary=---------------------------7dc18d1fb014a
Accept-Encoding: gzip, deflate
Host: 10.5.13.21
Content-Length: 933464
Connection: Keep-Alive
Cache-Control: no-cache
-----------------------------7dc18d1fb014a
Content-Disposition: form-data; name="uploader"
root
-----------------------------7dc18d1fb014a
Content-Disposition: form-data; name="image"; filename="test.jpg"
Content-Type: image/pjpeg
... contents of test.jpg ...
-----------------------------7dc18d1fb014a--
详细讲解,参见http://www.cnblogs.com/ryhan/archive/2011/08/09/2132509.html