The HTTP protocol enables web servers and browsers to exchange data over the Internet
HTTP is connectionless - no connection is ever maintain.
HTTP is media independent - any type of file can be send, as long as client and server accept it.
vocab: CRLF - carriage return line feed
URL format
protocol://[host.]domain[:port][/context][/resource][?query string]
or
protocol://IP address[:port][/context][/resource][?query string]
HTTP request format
An HTTP request consists of three components:
Initial Line
Header Lines
Message Body
Initial Line
Header1: value1
Header2: value2
Header3: value3
[Optional message body, the type of body is specified by Content-Type Header, for HTML file, the value is text/html]
Initial Lines
get
GET / HTTP/1.1
post( contain status code )
HTTP/1.0 200 OK or
HTTP/1.0 404 Not Found
Header Lines
Message Body
Example
A typical HTTP get example notice there is no message body in this GET request
GET / HTTP/1.1 Host: www.ifeng.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive Cookie: ALLYESID4=03BC203464090910; userid=1324935855700_3249; vjuids=36521e1c9.1347c54c390.0.7c3f30c6947c48; vjlast=1324935857.1344027154.11; samemappingcookie=m; py_map=1; ua_map=adchina; _plst[_plid_]=3536482416; weather_city=bj; Q37_visitedfid=144; pgv_pvi=4805773312; olyput=1344006725549%7C1344027257398 If-Modified-Since: Fri, 03 Aug 2012 20:50:57 GMT |
A typical HTTP response from server, There is no message body in this response. The response type is specified by Content-Type. If a web page is sent, then the content-type should be text/html
HTTP/1.1 200 OK Date: Sun, 10 Oct 2010 23:26:07 GMT Server: Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8 OpenSSL/0.9.8g Last-Modified: Sun, 26 Sep 2010 22:04:35 GMT ETag: "45b6-834-49130cc1182c0" Accept-Ranges: bytes Content-Length: 13 Connection: close Content-Type: text/html Hello world! |
Reference:
http://www.tutorialspoint.com/http/index.htm
http://en.wikipedia.org/wiki/HTTP_body_data