HTTP request format: four parts of the request format: Request Line Information, request header information, blank line information, request body information,
Post/day04-http/index.html HTTP/1.1 // request line information
Accept: text/html, application/XHTML + XML, */* // request header information Referer: http: // localhost: 8080/day04-http/index.html
Accept-language: ZH-CN
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Content-Type: Application/X-WWW-form-urlencoded
Accept-encoding: gzip, deflate
HOST: localhost: 8080
Content-Length: 10
Connection: keep-alive
Cache-control: No-Cache
// Blank line information: separates response header information and response body information
Name = fdghd // Request body information
I. Request Line Information: Post/day04-http/index.html HTTP/1.1 request line information is divided into three parts 1) Request Method: Post get: This method will take? And & Symbol are explicitly displayed in the address bar. Therefore, this mode is transmitted in plaintext and limited resources are transmitted. Post: the data submitted in this method will be stored in the Request body, but it is also clear code, but it can transmit a large amount of data information 2) request resources: /day04-http/index.html/website name/specific resource name if it is get method is:/website name/specific resource name? Name = shfj3) Request Protocol: HTTP/1.1 request protocol/version number
The difference between http1.0 and http1.1: 1.0 is an earlier version. In this version, a TCP/IP connection is established for each browser request (secure) relatively time-consuming 1.1 This version is later. If the browser's nuclear weapons need to be connected, then the server and the browser
2. The request header is sent by the browser to the server, mainly to notify the server of some events such as accept: text/html, application/XHTML + XML, and */* // to notify the server, browser acceptable data type Referer: http: // localhost: 8080/day04-http/index.html // Notification Server, reference path when the browser requests
Accept-language: ZH-CN // indicates the language type acceptable to the browser.
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) // Notification Server, who is the proxy software used to access the Internet?
Content-Type: Application/X-WWW-form-urlencoded
Accept-encoding: gzip, deflate // Notification Server, type of resources that the browser can receive
HOST: localhost: 8080 // specify the Host Name of the requested resource
Content-Length: 10
Connection: keep-alive
Cache-control: No-Cache
HTTP format: Response line information, response header information, blank line information, response body information HTTP/1.1 200 OK response Line Information
Server: APACHE-Coyote/1.1 // response header information
Accept-ranges: bytes
Etag: W/"386-1362317486015"
Last-modified: Sun, 03 Mar 2013 13:31:26 GMT
Content-Type: text/html
Content-Length: 386
Date: Sun, 03 Mar 2013 13:32:27 GMT
// Blank line information
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd"> // response body information
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> insert title here </title>
</Head>
<Body>
<Form action = "" method = "Post">
Name: <input type = "text" name = "name"/>
<Input type = "Submit" value = "Submit"/>
</Form>
</Body>
</Html>
1. Line Information: HTTP/1.1 200 OK 1) response protocol/version 2) Status Code 0 ~ 600
Common status codes:
200 successful response
304 the browser needs to continue sending requests to refine the original requests
404 resource does not exist
500 an exception occurred on the server
3) Description of the response status code II. Response Header Information Server: APACHE-Coyote/1.1 // name of the server that processes the request
Accept-ranges: bytes
Etag: W/"425-1362322259204"
Last-modified: Sun, 03 Mar 2013 14:50:59 GMT
Content-Type: text/html
Content-Length: 425
Date: Sun, 03 Mar 2013 14:51:57 GMT