[Depth] HTTP protocol - 1565075570.4519832

table of Contents

Original link: http://106.13.73.98/__/80/

HTTP is an abbreviation (Hyper Text Transfer Protocol) Hypertext Transfer Protocol.

HTTP is the result of the development of World Wide Web Consortium (World Wide Web Consortium) and the Internet Working Group IETF (Internet Engineering Task Force) collaboration, (they) finally issued a series of RFC.

RFC 1945 defines the HTTP / 1.0 version, most notably RFC 2616, RFC 2616 defines a widely used version today --HTTP 1.1

------->

HTTP protocol (Hyper Text Transfer Protocol) Hypertext Transfer Protocol is used for transmission from the WWW server Hypertext Transfer Protocol to the local browser.

It can make the browser more efficient, so that network traffic is reduced. Not only does it ensure that the computer correctly and quickly transfer hypertext document, the document also determines which part of the transmission, and which first part of the show (such as text prior to graphics) and so on.

@

HTTP response model
·
HTTP protocol is always initiated by the client request, the server sends the response back, as shown below:
Here Insert Picture Description
This limits the use of HTTP protocol, can not be achieved when the client did not initiate the request, the server pushes the message to the client.

HTTP workflow
·
一次HTTP操作称为一个事务course of their work can be divided into four steps:

  1. First, the client and the server needs to establish a connection. Just click on a hyperlink, HTTP work began.
  2. After the connection is established, the client sends a request to the server, the request means the format: Uniform Resource Identifier (URL), the protocol version
    is behind the MIME (statement text information) information includes a request modifiers, client information and possible content.
  3. Server upon request, to give the corresponding response information, the format of a status line comprising a protocol version number information, a success or error code
    back is a MIME information includes server information, entity information and possible content.
  4. The client receives the information returned by the server and the user on the display screen, and the client disconnects from the server through a browser.

·
If an error occurs in the course of more than a step, then an error message will be returned to the client by the display output.
For users, these processes are done by the HTTP themselves, users simply use the mouse to click and wait for information show on it.
***

HTTP request

HTTP request method Daquan
No. method description
1 GET Request page information specified, and returns the entity body.
2 HEAD Similar to get request, but the response is not returned in the specific content, for obtaining the header
3 POST Submitting data to the processing request specified resource (e.g., file submission form or upload). Data contained in the request body. POST request may result in a revision to establish and / or existing resources to new resources.
4 PUT Data transmitted from the client to the server designated to replace the contents of the document.
5 DELETE Requests the server to delete the specified page.
6 CONNECT HTTP / 1.1 protocol can be reserved for connection to the proxy server pipeline mode.
7 OPTIONS It allows the client to view server performance.
8 TRACE Echo request received by the server, mainly for testing or diagnosis.
9 PATCH Entity comprises a table, the table illustrates the differences in the contents of the original URI indicated.
10 MOVE The server will request the specified page to another web address.
11 COPY The request server to another copy of the page specified by the network address.
12 LINK Requests the server to establish a link relationship.
13 UNLINK Unlink relationship.
14 WRAPPED It allows the client sends a request through the package.
15 Extension-mothed Without modification of the protocol, another method may be increased.
The HTTP request includes

·
客户端连上服务器后,向服务器请求某个Web资源,称之为客户端向服务器发送了一个HTTP请求.
·
一个完整的HTTP请求包括的内容:一个请求行、若干消息头、实体内容.
·
Below:
Here Insert Picture Description

Details HTTP request - the request header

·
Request line is called the GET request method, request methods are: POST, GET, HEAD, OPTIONS , DELETE, TRACE, PUT, commonly used are: GET, POST
-
users, if not set, the default browser to the server GET requests are sent, for example, lose access address directly into your browser, hyperlink access points are all GET, such as the user wants to change the way POST request, can be changed to achieve a form of submission through.
*
Whether POST or GET, are used to request a WEB server resources, the difference between these two methods is mainly reflected in the data transfer:? If the request method is GET method, it is possible to bring the form to the data server in the URL address request , & among the plurality of data separated, for example: the GET /mail/1.html?name=abc&password=xyz the HTTP / 1.1
·
GET请求的特点:在URL地址后附带的参数是有限制的,其数据容量通常不能超过1K.
·
If the request mode, may be sent to the server POST method request entity content features data, Post manner: unlimited amount of data transferred.

Details HTTP request - message header

·
Accept
Statement browser supported data types
·
Accept-Charset
statement browser supports character sets
·
Accept-Encoding
statement browser supports compression format
·
Accept-Language
statement browser locale
·
Host
statement browser to access that host
-
If-Modified-since
declaration time browser cache data
·
Referer
Statement which pages to the client for security chain
-
Connection
browser tells the server through the head, after the request is broken links or maintaining links
·
X-Requested-with: XMLHttpRequest
representatives access via ajax
-
User-Agent
identity of the carrier request, the browser identification
·
more It is used in the HTTP request header, as shown below:
Here Insert Picture Description
***

HTTP response

HTTP response including the

·
HTTP response on behalf of the server to the client to send data back end.
它包括:一个状态行、若干消息头、以及实体内容.
Here Insert Picture Description

Details HTTP response - the status line

·
Status line format:
HTTP/1.1 200 OK HTTP status code version reasons described <CRLF>
·
status code is used to indicate the processing result of the request to the server.
Status code is a three-digit decimal number, the response status code is divided into five categories.
Here Insert Picture Description
·
Common HTTP status code
·
100 客户端应继续发送请求
remaining portion of the client should continue to send the request, the client should continue to send the request.
or if the request has been completed, the response is ignored.
·
101 转换协议
in the last empty row after transmission of the response, the server will switch to the message Upgrade those protocols defined in the head.
only in switching to a new agreement is more beneficial when it should take similar measures.
·
102 继续处理
by the WebDAV (RFC 2518) extension of the status code, the request will be representatives continue.
·
200 请求成功
expressed this request Implementation of successful
treatment: get content of the response, for processing.
·
201 请求完成
expressed this request execution completed the
result is the creation of a new resource, URL resource newly created available in solid response.
treatment is not in reptiles in experience.
·
202 请求被接受
request has been accepted, but the process is not complete.
Disposition: obstruction wait.
·
204 服务器以实现请求
server has fulfilled the request, but did not return the new Information
If the client is a user agent is not required for the update its document view.
Disposition: Discard
·
300
The status code is not used directly to HTTP / 1.0 application, just as the default interpretation 3XX response type, there is a plurality of available resources is requested.
Processing way: If the program can be processed, the further processing; if the program can not be processing, discard
-
301 永久重定向
request to the resource is assigned a permanent URL, so that you can access this resource by the URL in the future.
Disposition: redirected to the URL assigned a permanent redirect.
·
302 临时重定向
request to a resource temporarily stored at a different URL.
treatment: temporary redirect to the URL, temporary redirects.
·
304 请求的资源未更新
requested resource is not updated.
using a local cache file (a request will not be sent).
treatment: discard
·
400 非法请求
treatment: discarded.
·
401 未授权
treatment: discarded.
·
403 禁止
treatment: discarded.
·
404 没有找到
treatment: discarded.
·
500 服务器内部错误
the server encountered an unexpected condition that causes it can not complete the processing of the request.
generally this problem an error occurs on the server-side source code the event.
That is a server problem, code logic problems.
·
501 服务器无法识别
server does not support a feature request for the current need.
when the server no When the method of the identification request process, which will not support any requests for resources.
*
502 错误网关
As a gateway or proxy server attempts to perform the requested work, the server receives from the upstream to the invalid response.

HTTP response Details - Common Response Header

·
Location
Server through the head, to tell the browser to jump to where
·
Server
declaration server model
·
Content-Encoding
server through the head, telling the browser, the compressed data format
·
Content-Length
statement server returns the length of the data
-
Content-Language
server through the head, telling the browser language environment
·
Content-Type
statement server returns the type of data
-
Refresh
server through the head, telling the browser periodically refresh
·
Content-Disposition
server through the head, telling the browser to download the open the data
-
Transfer-Encoding
server through the head, telling the browser data is blocking the way loopback the
·
Expires: -1
control the browser not to cache
·
Cache-Control: no-cache
· more: http: //tools.jb51.net/table/http_header
Pragma: no-cache


Guess you like

Origin www.cnblogs.com/gqy02/p/11309099.html