Interview questions: HTTP must know--common face test summary

Source: Internet
Author: User

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 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
200: request is handled normally
204: Request is accepted but no resources can be returned
206: The client is only a part of the requested 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 Redirection
302: Temporary redirection
303: Similar to the 302 status code, except that it expects the client to redirect to another URI by the Get method when requesting a URI
304: Returns when the 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
400: The request message syntax is wrong, the server is not recognized
401: Request requires authentication
403: The requested corresponding resource is forbidden to be accessed
404: The server cannot find the corresponding resource
500: 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

Interview questions: HTTP must know--common face test summary

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.