HTTP protocol "detailed"--classic face question

Source: Internet
Author: User
Tags emit ranges

---restore content starts---

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 has beenA URI (Uniform Resource Identifier) that identifies a resource that can be passed to the server via a URL.
POST:for transmitting information to the server, the main functions andThe Get method is similar, but it is generally recommended to use post mode.
PUT:transfer file, the message body contains the contents of the file, save to the correspondingThe URI location.
HEAD:get the message header, andThe Get method is similar, but does not return the text body, generally used to verify that the URI is valid.
DELETE:delete files, andIn contrast to the Put method, delete the file that corresponds to the URI location.
OPTIONS:Query the appropriateThe HTTP method supported by the 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 http://127.0.0.1/Test/login.action?name=admin&password=admin, 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:requests are entertained but no resources can be returned
206:The client is only part of the requested resource, and the server executes only the part of the requested resourceA Get method that content-range a specified range of resources in the corresponding message.
301:Permanent Redirection
302:Temporary redirection
303:with the302 The status code has a similar function, except that it expects the client to redirect to another URI by the 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, with302 similar, just forcing the use of the Post method
:the request message syntax is incorrect and 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, General header field (the header field used for both request and response messages)
Date: Create message Time
Connection: Management of the connection
Cache-control: Cached control
Transfer-encoding: Transmission encoding of the message body
B, Request Header Field (the header field used for request messages)
Host: The server on which the resource is requested
Accept: The type of media that can be processed
Accept-charset: Acceptable Character set
Accept-encoding: acceptable content encoding
Accept-language: Acceptable natural language
C, Response header field ( Span style= "font-family: Microsoft Black" > header field to be used for response messages)
Accept-ranges: Acceptable byte range
Location: URI to redirect client to
Installation information for the SERVER:HTTP server
D, Entity header field (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: The type of the entity main class
Content-encoding: The encoding method that the entity body applies to
Content-language: Natural language of the entity body
Content-length: The number of bytes of the entity body
Content-range: The position range of the entity body, typically used to emit partial requests using


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

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

8. HTTP optimization

optimize and accelerate with load balancing HTTP application

Use HTTP cache to optimize your Web site

---restore content ends---

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 has beenA URI (Uniform Resource Identifier) that identifies a resource that can be passed to the server via a URL.
POST:for transmitting information to the server, the main functions andThe Get method is similar, but it is generally recommended to use post mode.
PUT:transfer file, the message body contains the contents of the file, save to the correspondingThe URI location.
HEAD:get the message header, andThe Get method is similar, but does not return the text body, generally used to verify that the URI is valid.
DELETE:delete files, andIn contrast to the Put method, delete the file that corresponds to the URI location.
OPTIONS:Query the appropriateThe HTTP method supported by the 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 http://127.0.0.1/Test/login.action?name=admin&password=admin, 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

Common status codes, status descriptions, descriptions
£ ºrequest is handled normally
204:requests are entertained but no resources can be returned
206:The client is only part of the requested resource, and the server executes only the part of the requested resourceA Get method that content-range a specified range of resources in the corresponding message.
301:Permanent Redirection
302:Temporary redirection
303:with the302 The status code has a similar function, except that it expects the client to redirect to another URI by the 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, with302 similar, just forcing the use of the Post method
:the request message syntax is incorrect and 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, General header field (the header field used for both request and response messages)
Date: Create message Time
Connection: Management of the connection
Cache-control: Cached control
Transfer-encoding: Transmission encoding of the message body
B, Request Header Field (the header field used for request messages)
Host: The server on which the resource is requested
Accept: The type of media that can be processed
Accept-charset: Acceptable Character set
Accept-encoding: acceptable content encoding
Accept-language: Acceptable natural language
C, Response header field ( Span style= "font-family: Microsoft Black" > header field to be used for response messages)
Accept-ranges: Acceptable byte range
Location: URI to redirect client to
Installation information for the SERVER:HTTP server
D, Entity header field (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: The type of the entity main class
Content-encoding: The encoding method that the entity body applies to
Content-language: Natural language of the entity body
Content-length: The number of bytes of the entity body
Content-range: The position range of the entity body, typically used to emit partial requests using


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

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

8. HTTP optimization

optimize and accelerate with load balancing HTTP application

Use HTTP cache to optimize your Web site

HTTP protocol "detailed"--classic face question

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.