HTTP protocol (continuous update)

Source: Internet
Author: User
Tags browser cache

The HTTP request consists of three parts: the request line, the message header, the request body

HTTP (Hypertext Transfer Protocol) is a request-and-response mode-based, stateless, application-level protocol, often based on TCP connection, HTTP1.1 version of a continuous connection mechanism, the vast majority of web development, is built on the HTTP protocol on the Web application.

1. What are the common HTTP methods?
get: used to request access to a resource that has been identified by a URI (Uniform Resource Identifier) that can be passed to the server via a URL.
Post: for transmitting information to the server, the main function is similar to the Get method, but it is generally recommended to use post mode.
PUT: transfer file, message body contains the contents of the file, save to the corresponding URI location.
HEAD: Gets the message header, similar to the Get method, but does not return the text body, generally used to verify that the URI is valid.
Delete : Delete the file, as opposed to the Put method, to delete the file that corresponds to the URI location.
OPTIONS: Query the HTTP method supported by the corresponding URI.

2. The difference between the Get method and the Post method
Difference One:
Get focus on getting resources from the server, post focus on sending data to the server;
Difference Two:
Get transfer data is sent through a URL request, in the form of field (fields) = value, placed after the URL and used with "?" Connection, with "&" connection between multiple request data, such as, this process user is visible;
Post transmission data through the post mechanism of HTTP, the field and corresponding values are sealed in the request entity sent to the server, the process is not visible to the user;
Difference Three:
Get transmits a small amount of data because it is limited by URL length, but is more efficient;
Post can transmit a large amount of data, so you can only use post when uploading files;
Difference Four:
Get is unsafe because URLs are visible and may reveal private information, such as passwords, etc.;
Post is higher security than get;
Difference Five:
The Get method can only support ASCII characters, and Chinese characters passed to the server may be garbled.
The post supports the standard character set, which correctly passes Chinese characters.

3. HTTP request message and Response message format

The request message contains three parts:
A, request line: Contains the request method, URI, HTTP version information
B. request header Field
C. Request Content Entity
The response message contains three parts:
A, status line: Contains the HTTP version, the status code, the status code of the reason phrase
B, Response header field
C, Response content entity

4, the common HTTP corresponding status code

The returned state
1XX: Indication information--Indicates that the request has been received and continues processing
2XX: Success-Indicates that the request has been successfully received, understood, accepted
3XX: Redirect--further action is required to complete the request
4XX: Client Error--Request syntax error or request not implemented
5XX: Server-side error-the server failed to implement a legitimate request

$: request is handled normally
204: request is accepted but no resources can be returned
206: The client is simply a part of the request resource, and the server executes the Get method only for the requested part of the resource, and the corresponding message is Content-range the specified range of resources.
301: Permanent redirect
302: Temporary redirection
303: Similar to the 302 status code, except that it expects the client to be redirected to another URI by a get method when requesting a URI
304: returns when a condition is not satisfied when sending a request with a condition, regardless of redirection
307: temporary redirection, similar to 302, just forcing the use of the Post method
: The request message syntax is wrong, the server is not recognized
401: Request authentication Required
403: The requested corresponding resource is forbidden to be accessed
404: The server cannot find the corresponding resource
: Server Internal Error
503: the server is busy

5, HTTP1.1 version of the new features
A, the default persistent connection to save traffic, as long as the client service side does not explicitly make a disconnect TCP connection, has remained connected, can send multiple HTTP requests

B, Pipeline, the client can make multiple HTTP requests at the same time without waiting for a response

C, the principle of the continuation of the breakpoint

6. Common HTTP header fields
A, the General header field (the header field used by the request message and the response message)
Date: Create Message time
Connection: Management of connections
Cache-control: Cache Control
Transfer-encoding: Transmission encoding method of message body
B, Request header field (the header field used by the request message)
Host: The server on which the resource is requested
Accept: Types of media that can be processed
Accept-charset: A character set that can be received
Accept-encoding: Acceptable content encoding
Accept-language: Acceptable Natural language
C, Response header field ( the header field used by the response message)
Accept-ranges: Acceptable byte range
Location: The URI to which the client is redirected
Installation information for the SERVER:HTTP server
d, the Entity header field (the header field used by the entity portion of the request message and the response message)
Allow: The HTTP method supported by the resource
Content-type: Type of entity main class
Content-encoding: The encoding method that the entity body applies To
Content-language: The natural language of the entity body
Content-length: The number of bytes of the entity Principal
Content-range: The position range of the entity body, which is typically used when making partial requests

7. HTTP Disadvantages and HTTPS
A, communication using clear text is not encrypted, content may be eavesdropping
b, do not verify the identity of the communication party, may be disguised
C, unable to verify message integrity, may be tampered with

HTTPS is HTTP plus cryptographic processing (typically SSL secure communication lines) + Authentication + integrity Protection

8. HTTP optimization

Optimize and accelerate HTTP applications with load balancing

Use HTTP cache to optimize your Web site

9, a page from the input URL to the page load display completed, what happened in this process? (The more detailed the process, the better)

    • Find browser cache
    • DNS resolves, locates the IP address of the domain name, redirects (301), and issues a second GET request
    • Making an HTTP protocol session
    • Client Send header (request header)
    • Document Start download
    • Document Tree establishes a file that specifies the MIME type required according to the tag request
    • File display
    • The work done on this side of the browser is broadly divided into the following steps:
    • Load: According to the URL of the request for Domain name resolution, to the server to initiate requests, receive files (HTML, JS, CSS, images, etc.).
    • Parsing: syntax parsing of loaded resources (HTML, JS, CSS, etc.), suggesting corresponding internal data structures (such as HTML DOM tree, JS (object) attribute table, CSS style rules, etc.)

HTTP protocol (continuous update)

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: 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.