HTTP protocol Basics

Source: Internet
Author: User

Message Composition method
    • Starting line (start lines);
    • The header (header) block containing the attribute;
    • Optional, body part that contains the data.

The syntax of the message
  • Requesting message (Request message)
    <method> <request-URL> <version>
    <entity-body>
  • Response message (Response message)
    <version> <status> <reason-phrase>
    <entity-body>
    Method
  • GET
    Get is the most common method, typically used to request that a server send a resource.

  • HEAD
    The head method behaves similarly to the Get method, but the server returns only the header in the response. The body part of the entity is not returned. This allows the client to check the header of the resource without obtaining the actual resources. This can verify that the server is valid

  • PUT
    Instead of reading the document from the server, the Put method writes the document to the server.

  • POST
    It is usually used to support HTML forms, and the data that is filled in forms is usually sent to the server and sent to other places by the server.

  • TRACE
    When a client initiates a request, the request may go through a firewall, proxy, gateway, or some other application. Each intermediate node may modify the original HTTP request. Trace allows the client to see what it looks like when it finally sends the request to the server.
    A trace request initiates a "loopback" diagnostic on the destination server. The server at the last stop of the trip bounces back a trace response and carries the original request message it received in the response body. This allows the client to see whether the original message, and how it was destroyed or modified, is on the request/response chain consisting of all intermediate HTTP applications.

  • The trace method is primarily used for diagnostics, but it does have drawbacks, assuming that the intermediate application handles the same processing for a variety of different types of requests (different methods--get, HEAD, post, and so on). For example, an agent might send a POST request directly to the server and send a GET request to another HTTP application (such as a Web cache). Trace does not provide a mechanism to differentiate these methods. Typically, an intermediary application determines how the trace request is handled.
    The trace request cannot have the body part of the entity. The entity body portion of the trace response contains an exact copy of the request received by the response server.
  • OPTIONS
    The options method requests the Web server to inform it of the various features it supports. You can ask what methods the server typically supports, or which methods are supported for certain special resources. (Some servers may only support specific operations for some special types of objects.)
    The client application provides a means to determine the optimal way to access various resources without actually accessing those resources.

  • DELETE
    What the Delete method does is request that the server delete the resource specified by the request URL. However, the client application cannot guarantee that the delete operation will be performed. Because the HTTP specification allows the server to revoke a request without notifying the client.
    • Status code

The HTTP status code is divided into five main categories.

    • 100~199--Informational Status Code
    • The http/1.1 introduces an informational status code to the Protocol.

  • 200~299--Success Status Code
  • These requests are usually successful when the client initiates the request. The server has a set of status codes that represent success, which correspond to different types of requests.

    • 300~399--REDIRECT Status code
    • The redirect status code either tells the client to use an alternate location to access the resource they are interested in, or it provides an alternative response instead of the content of the resource. If the resource has been moved, you can send a redirect status code and an optional location header to tell the client that the resource has been removed, and where it can now be found, so that the browser can transparently move to the new position without disturbing the user.



        • 400~499--Client Error status code
        • Sometimes the client sends something that the server cannot handle, such as a malformed request message, or, most commonly, a non-existent URL.


          • 500~599--Client Error status code
          • Sometimes the client sends a valid request and the server itself has an error. This may be the client encountered a server defect, or the server on the child elements, such as a network management resources, error.


HeaderThe first and the method work together to determine what the client and server can do. headers can be used to provide information in request and response messages, some headers are specific to a particular message, and some headers are more general. The first part can be a five main type.
    • General Header
These are common headers that both the client and server can use. can provide some very useful common functionality between the client, the server, and other applications. For example, the date header is a generic header that can be used at each end to describe the time and date the message was built.
the Universal cache header is http/1.0 introduced the first to allow the HTTP application to cache the local copy of the object, so that it does not have to always be obtained directly from the source-side server.
    • Request Header
a request header is a header that is meaningful only in the request message. The user explains who or what is sending the request, where the request originated, or the client's preferences and capabilities. The server can try to provide a better response to the client based on the client information of the request header.
    1. Accept Header
the Accept header provides a way for the client to inform the server of its preferences and capabilities so that the server can make more informed decisions about what to send, based on this additional information. The Accept header will benefit both ends of the connection.

2. Conditional request Header Sometimes the client wants to add some restrictions to the request. For example, if the client already has a copy of the document, it wants the server to transfer the document only if the document on the server differs from the client-owned copy. With conditional request headers, the client can add this restriction to the request, requiring the server to ensure that a condition is true before responding to the request.
3. Security Request Header HTTP itself supports a simple mechanism to challenge/respond to requests for authentication. This mechanism requires the client to authenticate itself before acquiring a specific resource, so that things can be slightly more secure, and other security mechanisms implemented on top of HTTP are discussed.
4. Proxy request Header
    • Response header
The response message has its own response header set. The response header provides some additional information to the client, such as who is sending the response, the function of the responder, and even some special instructions related to the response. These headers help the client to process the response and initiate a better request in the future.
1. Negotiation header If there are multiple representations of resources-for example, if the server has French and German translations for some documents, http/1.1 can provide the server and client with the ability to negotiate resources.
2. Security response header we have seen the security request header, which is essentially the response side of the HTTP Challenge/response authentication mechanism.
    • Entity Header
There are many headers that can be used to describe the payload of an HTTP message. These headers may appear in both types of messages because the entity portion may be included in the request and response messages. The entity header provides a large amount of information about the entity and its content, from information about the object type to the various valid request methods that can be used on the resource. In summary, the entity header can tell the recipient of the message what it is dealing with.
1. Content Header the content header provides specific information about the entity, describes its type, size, and other useful information needed to process it. For example, a Web browser can learn how to display objects by looking at the type of content returned.
2. Entity Cache Header the generic cache header describes how or when to cache. The cache header of an entity provides information about the cached entity-for example, the information needed to verify that a cached copy of the resource is still valid, and a clue to better estimate when the cached resource is invalidated.



HTTP protocol Basics

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.