HTTP message (HTTP authoritative Guide chapter III)

Source: Internet
Author: User
HTTP Message

This chapter will introduce:
-How the message flows
-three components of an HTTP message
-the difference between the request and the corresponding message
-Various functions for request message support
-Various status codes returned with the response message
-All kinds of HTTP headers are used for what?
1. Message Flow
Message flow between client, server and agent, the term "inflow", "outflow", "upstream", "downstream" are used to describe the direction of the message
-Message flow to the source-side server
HTTP uses the term "inflow" and "outflow" to describe the direction of transaction processing. Message flows to the source server, after the work is completed, will flow back to the user's agent
-Packet Flow downstream
All the sender of the message is the upstream of the receiver, whether the request message or response message, all messages will flow downstream
2. Components of a message
The message contains three parts:
-Start line, description of the message
-Header, containing attributes
-Body, optional include data
The Start row and header are ASCII text separated by rows, ending with a carriage return and a newline character.
-The syntax of the message
The format of the request message is:

<method> <request-URL> <version>     

The format of the response message is:

<version> <status> <reason-phrase>  

The following sections are briefly described:
-Method
The action that the client wants the server to perform on the resource is a single word
-Request URL
Name the requested resource
-Version
HTTP version of the message used, in the format of http/<major>.<minor>
-Status Code
A three-digit number describes what happened during the request
-reason Phrases
A readable version of the numeric status code that contains all the text before the line termination sequence
-Header
can have 0 or more header, (First Name: value)
-The body part of the entity
Blocks of data made up of arbitrary data
3. Methods
HTTP defines a set of methods called security methods, and the get and head methods are safe because they do not produce results on the server
Here are some common methods:
-Get a document from the server that does not contain the principal
-Head only gets the header of the document from the server does not contain the principal
Using head, you can:
A. Knowledge of resources without access to resources (determining their type)
B. See if an object exists by looking at the status code in the response
C. Test whether the resource has been modified by looking at the header
-Post sends to the server the data that needs to be processed contains the principal
The Post method was initially used to input data to the server, and it is actually used to support HTML forms. The data that is filled out in the form is usually sent to the server, which is then sent by the server to where he is going.
-Put stores the principal part of the request on the server containing the principal
The semantics of the Put method is to have the server create a new document with the requested URL named with the main part of the request, and if that URL already exists, replace it with the subject.
-Tarce tracking of messages that might be sent to the server via a proxy server does not contain the principal
A request may pass through multiple intermediate nodes, and each intermediate node modifies the original HTTP request. The trace method allows the client to see what it becomes when it eventually sends the request to the server.
The trace request initiates a "return" diagnostics on the destination server, and the server at the last stop of the trip bounces back a trace response and carries the original request message in the response topic so that the client can see how the original message was modified.
The trace method is primarily used for diagnostics and is a good tool for viewing the effects of agents and other applications on user requests
-Optons determines which methods can be executed on the server that do not contain the principal
The option method requests the Web server to tell the various features it supports, asking the server what methods it usually supports, or what methods are supported for certain special resources
-delete Deletes a document from the server
What the Delete method does is ask the server to delete the resource set by the request URL, but the client application cannot guarantee that the deletion must be performed because the HTTP specification allows the server to revoke the request without notifying the client
Not all servers can implement these methods, and other servers may have their own methods, called extension methods
Web Publishing extension Methods sample:
-Lock allows a user to lock a resource (when editing a resource, lock it in case someone else modifies it at the same time)
-Mkcol allows users to create resources
-Copy facilitates replication of resources on the server
-Move resources on the server
4. Status Code
The HTTP status code is divided into 5 major categories
Status Code categories:
1.100-199 Informational Status Codes
-Status code continue the initial portion of the request is received and the client is requested to continue. After the status code has been sent, the server must respond after receiving the request
In many ways, continue is an optimization, and the client application should use Contiune when it avoids sending a large entity to the server that cannot be processed or used by the server.
If the server receives a expect header request with a value of continue, it responds with a continue response or an error.
-Status code switching protocols indicates that the server is switching the protocol to the protocol 200-299 success status code listed in the update header according to the client's designation
200
OK, there is a problem with the request, the body part of the entity contains the requested resource 201
Created, for creating a request for a server object (such as put). The entity body part of the response should contain a variety of resources you have created Url,location header contains the most specific reference 202
Accept, the request has been accepted, but the server has not performed any action on it. There is no guarantee that the server will complete this request, it simply means that when the request is received it looks 203 valid
Non-authoritative, the entity header contains information not from a source-side server, but from a copy of a resource 204
No Content, the response message contains a number of headers and a status line, but no body part of the entity 205
Reset Content, is responsible for informing the browser to clear the current page of all HTML table cell element 206
Partial Content, successfully executed part of request 300-399 redirect status code
300
Multiple choices returns this status code when requesting a URL that actually points to more than one resource 301
Moved permanently, the requested URL has been removed 302
Found, similar to the 301 status code, but the client should use the URL given by the location header to temporarily locate the resource, and future requests should still use the old URL 303
Please tell the client that you should use another URL to get the resource 304
Not Modefie 305
Use proxy, resource 307 must be accessed through a proxy
Temporary redirect, similar to a 301 status code, but the client should use the URL given by the location header to temporarily locate the resource, and future requests should still use the old URL 400-499 400-415 client error 500-599 500-505 Server error
500
Internal Server error, this status code 501 is used when the servers encounter an error that prevents it from servicing the request
Not implemented, client-issued request exceeds the server's capability range 502
Bad gateway, use this status code 503 when the server used as a proxy or gateway receives a pseudo response from the next link in the request response face.
Service unavailable to indicate that the server is unable to service the request at this time, but in the future it can be 504
Gateway Timeout, the response from a gateway or proxy, that timed out 505 when it waited for another server to respond to its request
Http version not supported, the server was requested to use a protocol version that it could not or would not support
HTTP can be divided into the following categories of headers: Universal header
The request header can appear in the request message or in the response message now.
Provide more information about the request response header
Provides more information about the first entity header for a response
Describes the length and content of the subject, or the resource itself expands the header
New header not defined in the specification
Common First Instance: Date:tue 3OCT 2016 02:16:03 GMT Server produces a response date content-length:12240 the body portion of the entity contains 12240 bytes of data content-type:image/gif The body part of an entity is a GIF picture accept:image/gif,image/jpeg,text/html the format that the client can receive
Increasing the length of the first section to multiple lines can improve readability by having at least one space or tab in front of each line

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.