HTTP protocol version Differences (2)

Source: Internet
Author: User
Tags webp

————————————— http1.0/http1.1 ——————————————

Establish connection aspects

http/1.0 each request requires a new TCP connection and the connection cannot be reused. http/1.1 a new request can be created at the last request
TCP connections are sent above, and connections can be reused. The advantage is to reduce the overhead of repeating the TCP three handshake and increase the efficiency. Note: In the same TCP connection
Next, the new request needs to wait until the last request receives a response before it can be sent.

HTTP request method
HTTP requests can use a variety of request methods, depending on the HTTP standard.
HTTP1.0 defines three methods of request: GET, POST, and head.
HTTP1.1 has five new request methods: Options, PUT, DELETE, TRACE, and CONNECT methods.

Request header Information
The request header information is made up of a head field.
Each header field consists of a domain name, a colon (:), and a domain value of three parts. Domain names are case-insensitive, any number of spaces can be added before domain values
, the header field can be expanded to multiple lines, at the beginning of each line, with at least one space or tab.
For example:

host:192.168.1.104:8888

The following example is a typical example of using get to pass data:
Client Request:

Get/hello.txt http/1.1user‐agent:curl/7.16.3 libcurl/7.16.3 openssl/0.9.7l zlib/1.2.3host:www.example.comaccept‐ Language:en, MI

Server Response Message

The HTTP response is also made up of four parts: the status line, the message header, the blank line, and the response body.

Status code

When a viewer accesses a webpage, the browser of the viewer makes a request to the server where the page is located. When a Web page is received and displayed by the browser, this page
The server returns an information header (server header) that contains the HTTP status code to respond to the browser's request.
HTTP status code in English is HTTP status code.
The following are the common HTTP status codes:

    • 200-Successful request
    • 301-Resources (Web pages, etc.) are permanently transferred to other URLs
    • 404-The requested resource (Web page, etc.) does not exist
    • 500-Internal Server error

HTTP Status Code classification:

The HTTP status code consists of three decimal digits, the first decimal number defines the type of the status code, and the latter two numbers do not have a function of classification.
There are 5 types of HTTP status codes:

HTTP Status Code list:

Response header Information
The HTTP request header provides information about the request, response, or other sending entity information.


Get response

ttp/1.1  $ok\r\nserver:tengine\r\ncontent‐type:application/octet‐stream\r\ncontent‐length:9568\r\nconnection:keep‐alive\r\ndate:wed, -Sep .  the: .: Agmt\r\nlast‐modified:wed, -Sep .  the: to: onGmt\r\ntiming‐allow‐origin:*, *\r\naccept‐ranges:bytes\r\nvia:cache1.l2et15[0,304‐0, H], cache10.l2et15[1,0], cache5.cn463[0, $‐0, h],cache5.cn463[0,0]\r\nage:3\r\nx‐cache:hit tcp_mem_hit dirn:‐2:‐2\r\nx‐swift‐savetime:wed, -Sep .  the: .: AGmt\r\nx‐swift‐cachetime:Ten\r\neagleid:9dff8b4514738439859887791e\r\n\r\n

Use the browser to send a get request such as:

http://192.168.1.104:8888?username=wenong&passwd=123456

Get/post comparison:

1)Getis used to get data from the server, andPostis used to pass data to the server.
2)GetFollow the data in the formVariable=valueThe form, added to theActionThe point ofUrlBack, and both use“?”Connection
And each variable is used between"&"ConnectionPostis to put the data in the form in the body of the data, according to the variables and values corresponding to the way, passed to theAction
The pointUrl。
3)Getis unsafe because in the transfer process, the data is placed in the requestedUrlMany servers, proxy servers, or
The user agent will requestUrlLog files and place them somewhere so that there may be some privacy information that is visible to third parties.
In addition, users can see the submitted data directly in the browser, and some system internal messages will be displayed in front of the user. All operations of the Post
are not visible to the user.
4) The amount of data sent is small, mainly because of the URL length limit, and Post can transfer a large amount of data, so the upload file can only
Use Post.

form submission GET< Span style= "FONT-FAMILY:SIMSUN; FONT-SIZE:10PT "> request, for example web index.html

<HTML><BODY><FORMACTION= "color.cgi"METHOD= "GET">Enter a color:<INPUTTYPE= "text"NAME= "Color"><INPUTTYPE= "Submit"></FORM></BODY></HTML>

GET Request

Get/color.cgi?color= http/1.1host:192.168.1.104:8888connection:keep‐aliveupgrade‐insecure‐requests:1user‐agent: mozilla/5.0 (Windows NT 10.0; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/51.0.2704.106 safari/537.36accept:text/html,application/xhtml+ Xml,application/xml;q=0.9,image/webp,*/*;q=0.8referer:http://192.168.1.104:8888/accept‐encoding:gzip, deflate, sdchaccept‐language:zh‐cn,zh;q=0.8

Form to submit a POST request, such as index.html in a Web server :

<HTML><BODY><FORMACTION= "color.cgi"METHOD= "POST">Enter a color:<INPUTTYPE= "text"NAME= "Color"><INPUTTYPE= "Submit"></FORM></BODY></HTML>

POST Request

post/color.cgi http/1.1host:192.168.1.104:8888connection:keep‐alivecontent‐length:10cache‐control:max‐age= 0origin:http://192.168.1.104:8888upgrade‐insecure‐requests:1user‐agent:mozilla/5.0 (Windows NT 10.0; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/51.0.2704.106 safari/537.36content‐type:application/x‐www‐form‐ urlencodedaccept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8referer:http:// 192.168.1.104:8888/accept‐encoding:gzip, Deflateaccept‐language:zh‐cn,zh;q=0.8color=read

HTTP protocol version Differences (2)

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.