An analysis of HTTP protocol GET request and POST request

Source: Internet
Author: User

I. INTRODUCTION of HTTP

1, HTTP protocol: (Hypertext Transport Protocol), that is, Hypertext Transfer Protocol. This protocol details the rules for communication between the browser and the World Wide Web server (message format).

 2. Message: the content that is transmitted when the client communicates with the server is what we call a message. the client is sent to the server called the " Request Message ", the server is sent to the client called " Response message."

3. Classification:

Request message:

GET request

POST request

Response message:

4. Message Format:

      Message header: Includes Wenshou and message header

Second, GET request message

GET request message only: message header

First line of message

GET/BOOKSTORE01/B.HTML?USERNAME=DFADF&PWD=DFA http/1.1 //Request way request path? parameter Key value pair &
      
Message Header "Key-value pair format"

host:localhost:8080//Request destination IP address and port number
        user-agent:mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) gecko/20100101firefox/27.0//Current browser

accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
//browser tells the server what format of file the browser can receive        

accept-language:zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
//You can tell which location you are in        
zh-cn: Simplified Chinese
en-US: American English

Accept-encoding:gzip, deflate
//browser tells the server that the browser can identify the decompression method        

referer:http://localhost:8080/bookstore01/index.html
//Referer: Refers to the page from which the current page is to jump over

connection:keep-alive
//keep-alive: Indicates that the browser tells the server that this is a long connection        

Get requests do not have blank lines and message bodies, get requests are passed through the address bar parameters!

Third, POST request message

    Request First Line

post/bookstore01/b.html http/1.1        //request Path Request Protocol/version number  

//request Header

host:localhost:8080
User-ag ent:mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) gecko/20100101 firefox/27.0
accept:text/html,application/xhtml+ xml,application/xml;q=0.9,*/*;q=0.8
accept-language:zh-cn,zh;q=0.8, en-us;q=0.5,en;q=0.3
Accept-encoding:gzip, deflate
referer:http://localhost:8080/bookstore01/index.html
connection:keep-alive

        Blank Line

Username=zhangsan //message body

The POST request has a blank line and a request body, and the POST request passes the request parameters through the request body!

Iv. Response Messages

     Response First line:

http/1.1 OK // Protocol Name/version number response status Code status descriptor

server:apache-coyote/1.1
Accept-ranges:bytes
etag:w/"262-1510560961503"
Last-modified:mon, 08:16:01 GMT
       GMT
Content-type:text/html
content-length:262
Date:mon, 08:44:55 GMT

An analysis of HTTP protocol GET request and POST request

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.