HTTP protocol Header

Source: Internet
Author: User

#########

#概览

#########

Hypertext Transfer Protocol (Http:hyper Text Transfer Protocol): used to send data in www mode. With TCP/IP protocol, it is a stateless protocol. The request/response model is used.

  

#########

#Http请求 Request

#########

The client sends a request to the server, looking at the graph:

  HTTP requests include:

1) Request method, URI (Uniform Resource Identity Uniform Resource Identifier question/23133/, URL: Uniform Resource Locator Symbol WWW.BAIDU.COM/QUESTION/23133/ ) Association Discussion Version

2) Request Header

3) \ n ( blank line )

4) Request data

 Get Request example, using Charles Crawl's Request:get/562f25980001b1b106000338.jpg http/1.1Host Img.mukewang.comUser-agent mozilla/5.0(Windows NT10.0; WOW64) applewebkit/537.36(khtml, like Gecko) chrome/51.0.2704.106safari/537.36Accept Image/webp,image/*,*/*;q=0.8Referer http://www.imooc.com/accept-Encoding gzip, deflate, sdchaccept-language zh-cn,zh;q=0.8

The first part: The Get Description request type is get,[/562f25980001b1b106000338.jpg] is the resource to be accessed, and the last part of the row illustrates the use of the HTTP1.1 version.

The second part: the request header, followed by the request line (that is, the first line) after the section, to explain the server to use additional information

From the second line to the request header, host will indicate the destination of the request. User-agent, both server-side and client script access to it, is an important basis for browser type detection logic. This information is defined by your browser and is automatically sent in each request, etc.

Part Three: blank line, a blank line behind the request header is required

Part IV: The request data is also called the principal, you can add any other data.

The request data for this example is empty.

 POST Request example, using the request:post that Charles crawled/HTTP1.1Host:www.wrox.comUser-agent:mozilla/4.0(Compatible; MSIE6.0; Windows NT5.1; SV1;. NET CLR2.0.50727;. NET CLR3.0.04506.648;. NET CLR3.5.21022) Content-type:application/x-www-form-urlencodedcontent-length: +Connection:keep-Alivename=professional%20ajax&publisher=Wiley The first part: The request line, the first line is the POST request, and the http1.1 version. The second part: The request head, the second line to the sixth line. Part Three: blank line, blank line in line seventh. Part IV: Request data, line eighth. 

#########

#Http响应 Response

#########

The HTTP response includes: Also consists of four parts, namely: status line, message header, blank line, and response body.

#########

#Http Request Method & Http1.1 & Http 1.0

#########

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.

GET     请求指定的页面信息,并返回实体主体。HEAD     类似于get请求,只不过返回的响应中没有具体的内容,用于获取报头POST     向指定资源提交数据进行处理请求(例如提交表单或者上传文件)。数据被包含在请求体中。POST请求可能会导致新的资源的建立和/或已有资源的修改。PUT     从客户端向服务器传送的数据取代指定的文档的内容。DELETE      请求服务器删除指定的页面。CONNECT     HTTP/1.1协议中预留给能够将连接改为管道方式的代理服务器。OPTIONS 允许客户端查看服务器的性能。TRACE 回显服务器收到的请求,主要用于测试或诊断。

The difference between get and post

      1. Get submitted data is placed after the URL, to split the URL and transfer data, the parameters are connected with &, such as editposts.aspx?name=test1&id=123456. The Post method is to put the submitted data in the body of the HTTP packet.

      2. The data size for get commits is limited (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.

      3. The Get method needs to use Request.QueryString to get the value of the variable, and the Post method takes the value of the variable by Request.Form.

      4. The Get method submits the data, which brings security problems, such as a login page, when the data is submitted via get, the user name and password will appear on the URL, and if the page can be cached or someone else can access the machine, the user's account and password can be obtained from the history record.

Reference: http://www.cnblogs.com/ranyonsue/p/5984001.html

HTTP protocol Header

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.