HTTP Authoritative Guide-http messages

Source: Internet
Author: User
Tags error status code

Before you begin this chapter, ask some questions, what is a message? How do I create a message? How to understand the message? And what are the uses of the message?

What is a message?

It can be understood that if HTTP is the messenger of the Internet, then the HTTP message is the parcel that it uses to carry things.

One, Message flow

An HTTP message is a block of data that is sent between HTTP applications. These blocks start with meta-information in textual form, which describes the content and meaning of the message, followed by an optional data section.

1. Incoming packets to the source-side server

HTTP uses terminology inflows and outflows to describe the processing of things.

The first step flows into the source-side server , and when the work is done, it is streamed back to the user's agent proxy .

2. Messages to the dirty swimming

All messages flow downstream, whether it is a request message or a response message.

II. components of the message

The HTTP message is a simple format data block.

They are made up of three parts: the starting line that describes the message, the header block containing the attribute, and the optional body part that contains the data.

1. Syntax of the message

All HTTP messages can be divided into two categories: Request messages and response messages. The request message will request an action from the Web server. The response message returns the result of the request to the client.

method, request URL, version, status code, reason phrase, header, body part of the entity

2. Start line

The starting line of the request message shows what to do, and the starting line of the response message shows what happened.

Request line: The starting line (method, URL), HTTP version of the request message (Request message).

Response Line: (Response message) HTTP version, number status code, reason phrase.

Methods:, post, put, trace, options, delete.

Status code

Reason phrase: It provides a textual interpretation of the status code.

Version number: The version number appears in the Http/x.y form in the start line of the request message and response message. The purpose of using the version number is to provide a clue to an application that uses HTTP to understand each other's capabilities and message formats. When comparing versions, each number is compared separately. HTTP/2.22 is higher than the http/2.3 version. 22>3

3. Header: Add some additional information to the request and response message.

4. The entity's body part:

Optional, is the load of HTTP messages, that is, the content of HTTP to transmit.

5. Version 0.9 of the message:

is an early version of the HTTP protocol. Is the originator, the protocol is simple.

Third, the method

1. Security methods

2.GET: Typically used to request a server to send a resource

3.HEAD: Only headers are returned in the server response, and the body part of the entity is not returned. Learn about resources without obtaining resources; Check the status code in the response to see if an object exists; Review the header to see if the resource has been modified. L

4.PUT: Want the server to write to the document. Because put allows users to modify content, many Web servers require a password to log in before the put is executed.

5.POST: Usually used in forms.

6.TRACE: The client initiates a request that may go through a firewall, proxy, gateway, or some other application. Each intermediate node may modify the original HTTP request. Whether and how the original message was destroyed and modified.

This method is mainly used for diagnosis. Used to verify that the admission is passed through the request/response chain. ..........

7.options:options requests the Web server to inform it of the various features it supports. The optimal way to access various resources is to be judged without actually accessing those resources.

8.DELETE: Ask the server to delete the resource specified by the request URL.

9. Extension method: Refers to a method that is not defined in the http/1.1 specification.

Four, status code

100-199 Informational Status Code  200-299 Success Status Code   300-399 REDIRECT Status code   400-499 Client Error status code 500-599 Server Error status code

V. Header

1. General Header: Provides the most basic information related to the message. The generic cache header, so that it does not have to always be obtained directly from the source-side server.

2. Request Header: (Request message) is used to describe who or what is sending the request, where the request originated, or the client's preferences and capabilities.

3. Response Header: (response message) to provide customers with some additional information. For example, who is sending a response, the function of the responder, or even some special instructions related to the response.

4. Entity header: The payload of the HTTP message. You can tell the recipient of the message what it is dealing with.

HTTP Authoritative Guide-http messages

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.