Go Web by the one. Some common knowledge records

Source: Internet
Author: User

HTTP request package (browser information)

Let's take a look at the structure of the request package, the request package is divided into 3 parts, the first part is called the request line, the second part is called the request header, the third part is the body (body). There is a blank line between the header and the body, as shown in the sample request package:

get/domains/example/http/1.1//Request Line: Request method request URI HTTP Protocol/Protocol version host:www.iana.org//server-side host name user-agent:mozilla/5.0 (Windows NT 6.1) applewebkit/537.4 (khtml, like Gecko) chrome/22.0.1229.94 safari/537.4//Browser Info accept:text/html,application/ xhtml+xml,application/xml;q=0.9,*/*;q=0.8//client can receive the mineaccept-encoding:gzip,deflate,sdch// Support for stream compression accept-charset:utf-8,*;q=0.5//client character encoding set//blank line for splitting the request header and message body//message body, requesting resource parameters such as post pass parameters
The HTTP protocol defines a number of request methods that interact with the server, with 4 basic types, get,post,put,delete. A URL address is used to describe a resource on a network, and the Get, POST, PUT, delete in HTTP corresponds to the search for this resource, add, change, delete 4 operations. Our most common is get and post. Get is typically used to get/query resource information, and post is typically used to update resource information.

The difference between get and post:

1. We can see that the GET request message body is empty and the POST request has a message body.

The data submitted by 2.GET is placed after the URL to ? split the URL and transfer data between the parameters to be & connected, such as EditPosts.aspx?name=test1&id=123456 . The Post method is to put the submitted data in the body of the HTTP packet.

There is a limit to the size of data submitted by 3.GET (because the browser has a limit on the length of the URL), and there is no limit to the data submitted by the Post method.

4.GET Way to submit data, will bring security issues, such as a login page, through the Get method to submit data, the user name and password will appear on the URL, if the page can be cached or other people can access the machine, you can obtain the user's account and password from the history record

HTTP response package, his structure is as follows:

http/1.1 ok//status Line server:nginx/1.0.8//server uses the name and version of the Web software Date:Date:Tue, Oct 04:14:25 gmt//send Time Content-type:text /html//the type of message sent by the server transfer-encoding:chunked//indicates that the sending HTTP packet is a connection:keep-alive//of the segmented outgoing connection status content-length:90// Body content Length//blank line to split message headers and body <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" ...//message body

The first line in the response package is called the status line, which consists of the HTTP protocol version number, the status code, and the status message.

The status code is used to tell the HTTP client whether the HTTP server produced the expected response. The 5 class status codes are defined in the http/1.1 protocol, and the status code is made up of three digits, and the first number defines the category of the response.

    • 1XX hint Message-Indicates that the request was successfully received and continues processing
    • 2XX Success-Indicates that the request has been successfully received, understood, accepted
    • 3XX Redirect-further processing is required to complete the request
    • 4XX Client Error-Request syntax error or request not implemented
    • 5XX server-side error-the server failed to implement a legitimate request

Go Web by the one. Some common knowledge records

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.