An overview of HTTP
HTTP（hypertext transport protocol），That is, hypertext transmission protocol. This protocol specifies the rules of communication between browsers and World Wide Web servers.
HTTPIt is a communication rule. The communication rule specifies the content format sent by the client to the server, and also specifies the content format of the client sent by the server. The format that the client sends to the server is called the request protocol, and the format sent by the server to the client is called the response protocol.
- HTTPHypertext transfer protocol, based on request / response mode.
- HTTPA stateless protocol
URL：The unified resource locator is a web site:Protocol name://domain name:port/Paths, such as:http://www.baidu.com
Two request agreement
The format of the request protocol is as follows:
Request first line; / / request mode request path protocol and version, for example: GET /index.html HTTP/1.1Request header information; / / request header name: request header content, that is, key:value format, for example: Host:locAlhostEmpty line; / / / / used to separate from the requestRequest body. / / GET no request body, only POST has a request body
The content that the browser sends to the server is this format, which can not be read by this format server. In the HTTP protocol, there are many requests, and the most commonly used are GET and POST.
HTTPThe default request method is GET
- No request body
- The data must be within 1K
- GETThe request data will be exposed to the browser’s address bar
GETRequest common operations:
- If you give URL directly in the browser’s address bar, it must be GET request.
- The hyperlinks on the page are also GET requests
- When a form is submitted, the form acquiescence uses the GET request, but it can be set to POST request.
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:zh-CN,zh;q=0.8 Cache-Control:no-cache Connection:keep-alive Cookie:csrftoken=z5H43ZwARx7AIJ82OEizBOWbsAQA2LPk Host:127.0.0.1:8090 Pragma:no-cache Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36 Name login/ requests ❘ 737 B transferred ❘ Finish: 5 ms ❘ DOMContentLoaded: 14 ms ❘ Load: 14 ms
- GET 127.0.0.1:8090/login HTTP/1.1：GETRequest, request server path is 127.0.0.1:8090/login, the agreement is 1.1;
- Host:localhost：The hostname of the request is localhost;
- *User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0：Information related to browsers and OS. Some websites display user’s system version and browser version information, which are obtained by obtaining User-Agent header information.
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8：Tell the server the type of document that the current client can receive, which actually contains * / *, which means anything can be received.
- Accept-Language: zh-cn,zh;q=0.5：The current client supported language can find language related information in the browser’s tool options.
- Accept-Encoding: gzip, deflate：The compressed format supported. When data is passed over the network, the server will compress the data and send it again.
- Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7：The code for client support;
- Connection: keep-alive：The client supports the way of linking, maintaining a link for a period of time, default to 3000ms;
- Cookie：JSESSIONID=369766FDF6220F7803433C0B2DE36D98：Because it is not the first access to this address, the Cookie sent in the request of the last server response is sent in the request, and the name of the Cookie is JSESSIONID.