Interview questions: HTTP must know and must know - a summary of common interview questions

1. What are the commonly used HTTP methods?
GET: Used to request access to resources identified by URI (Uniform Resource Identifier), which can be passed to the server through URL
POST: Used to transmit information to the server, the main function is similar to the GET method, but the POST method is generally recommended.
PUT: To transfer a file, the message body contains the file content and saves it to the corresponding URI location.
HEAD: Get the header of the message, similar to the GET method, except that it does not return the body of the message. It is generally used to verify whether the URI is valid.
DELETE: Deletes a file, in contrast to the PUT method, deletes the file at the corresponding URI location.
OPTIONS: Query the HTTP methods supported by the corresponding URI.


2. The difference between the GET method and the POST method
Difference 1:
get focuses on obtaining resources from the server, and post focuses on sending data to the server;
difference 2:
get transmits data through a URL request, in the form of field = value, Put it after the URL, and use "?" to connect, and use "&" to connect multiple request data, such as http://127.0.0.1/Test/login.action?name=admin&password=admin, this process is visible to the user;
Post transmits data through Http's post mechanism, which encapsulates fields and corresponding values ​​in the request entity and sends them to the server. This process is invisible to users;
Difference 3:
The amount of data transmitted by Get is small, because it is limited by the length of the URL, but the efficiency Higher;
Post can transmit a large amount of data, so you can only use Post method when uploading files;
Difference 4:
Get is insecure, because the URL is visible, and may reveal private information, such as passwords, etc.
Post is more secure than get high;
Difference 5: The
get method can only support ASCII characters, and the Chinese characters sent to the server may be garbled.
post supports standard character sets and can correctly pass Chinese characters.


3. Format of HTTP request message and response message The
request message consists of three parts:
a. Request line: contains request method, URI, HTTP version information
b, request header field
c, request content entity
The response message consists of three parts:
a , Status line: contains HTTP version, status code, reason phrase
b for status code, response header field
c, response content entity


4, common HTTP corresponding status codes
200: The request is processed normally
204: The 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 resource within the range specified by Content-Range in the corresponding message.
301: Permanent redirection
302: Temporary redirection
303: It has a similar function to the 302 status code, except that it hopes that when the client requests a URI, it can be redirected to another URI through the GET method
304: Send conditional When requesting, it will be returned when the conditions are not met. It has nothing to do with redirection.
307: Temporary redirection, similar to 302, but requires the use of the POST method.
400: The request message syntax is incorrect and the server cannot recognize it
. 401: The request requires authentication
403: The requested The corresponding resource is forbidden to be accessed
404: The server cannot find the corresponding resource
500: Internal server error
503: The server is busy


5. New features of HTTP 1.1
a. The default persistent connection saves traffic. As long as either end of the client server does not explicitly disconnect the TCP connection, the connection will always be maintained, and multiple HTTP requests can be sent.

b. Pipeline, the client can issue multiple HTTP requests at the same time, instead of waiting for a response one by one

c. The principle of resuming transmission from breakpoints



6. Common HTTP header fields
a, general header fields (header fields used by both request messages and response messages)
Date: time when the message was created
Connection: connection management
Cache-Control: cache control
Transfer-Encoding: message body
b. The request header field (the header field that the request message will use)
Host: the server where the requested resource is located
Accept: the media type that can be processed
Accept-Charset: the acceptable character set Accept- Encoding
: the acceptable content encoding
Accept-Language: Acceptable natural language
c, response header field (the header field that the response message will use)
Accept-Ranges: Acceptable byte range
Location: URI to redirect the client to
Server: HTTP server installation Information
d. Entity header field (the header field used by the entity part of the request message and the response message)
Allow: HTTP methods supported by the resource
Content-Type: The type of the main class of the entity
Content-Encoding: The encoding method applicable to the entity body
Content-Language: The natural language of the entity body
Content-Length: The number of bytes of the entity body
Content-Range: The location range of the entity body, generally used when making partial requests


7. Disadvantages of HTTP and HTTPS
a. The communication is not encrypted in plain text, and the content may be eavesdropped
. b. The identity of the communication party is not verified, and it may be disguised
. c. The integrity of the message cannot be verified, and it may be tampered with.

HTTPS is HTTP plus encryption processing (usually SSL secure communication line) + authentication + integrity protection

 

8. HTTP optimization

Optimize and accelerate HTTP applications with load balancing

Utilize HTTP Cache to optimize your website

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325332601&siteId=291194637