Home > other >  HTTP knowledge transfer (summary) after the interview
HTTP knowledge transfer (summary) after the interview

Time:12-16

The Http protocol interview questions summary original



HUAO2416

Read the 2017-09-01 number: 25035

Pay attention to

1. Say what is the Http protocol

To implement data transmission between client and server format specification, format referred to as "hypertext transfer protocol",


2. What is the Http protocol stateless? How to solve the Http protocol stateless?

(1), a stateless protocol for the transaction without memory ability, lack of state means that if the information in front of the subsequent processing need
(2), stateless protocol solution: by 1, 2, Cookie by Session Session,


3. Say the Http protocol in 302 state

The HTTP protocol, return a status code 302 indicates redirection,

In this case, the server returns the header information will contain a Location field, content is redirected to the url


4. The Http protocol consists of what?

Request message consists of three parts:

(1). Line request: version contains request method, URI, HTTP protocol

(2). Request header fields

(3). Request content entity

Response message contains three parts:

(1). The status line: contains the HTTP version, a status code, a status code reason phrase

(2). In response to the first field

(3). The response content entity


5. What are some of the request for the Http protocol?

The GET: to request access has been a URI (uniform resource identifier) identification of the resources, can use the URL to send ginseng to server

POST: used to transfer information to the server, the main function is similar to the GET method, but in general it is recommended to use the POST way

PUT: transfer files, files contained in the message subject content, saved to the corresponding position of URI

HEAD: GET the first message, similar to the GET method, just don't return a message subject, generally is used to validate the URI is effective

DELETE: DELETE the file, in contrast to the PUT method, DELETE the corresponding URI location file

OPTIONS: URI query response support HTTP method


6. Http1.0 and 1.1 the difference in the Http protocol?

In http1.0, after the connection is established, the client sends a request to the server returns a information and then close the connection, the next time when a browser requests and to establish a connection, obviously this connection way unceasingly, can cause a lot of problems,


7. The principle of the Http protocol implementation mechanism

(1). The whole process steps:



(2) the domain name resolution process:



(3). Three times handshake

(4). A Http request

(5). The response Http requests and get the HTML code

(6). The browser parses HTML

(7). The browser to render the page presented to the user


8. The difference between the get and post requests?

The difference between a: get focus on access to resources from the server, the post focused on to the server sends data;

Difference between two: get to transmit data through the URL request, to filed (field)=the value form, placed in the URL, and the "?" Connection between multiple requests data using

"& amp;" Connection, such as http://127.0.0.1/Test/login.action? Name=admin& User password=admin, this process is visible

Difference between three: get transfer quantity is small, because restricted by the length of the URL, but low efficiency

Post can transfer a large amount of data, so upload files can only be used when the post way

The difference between four: it is not safe to get, because the URL is visible, may disclose private information such as password, etc.

Post more get safety

9. The common Http protocol state

200: the request is normal processing
204: the request is accepted but no resources can return
206: the client is only part of the request resources, server resources to execute the request part only the GET method, the corresponding message through the Content - the Range in the specified Range of resources,
301: a permanent redirect
302: temporary redirect
: 303 and 302 status code has a similar function, but it wants the client requests a URI, can pass the GET method is redirected to another URI
304: send the request of the conditional, condition not satisfied return, has nothing to do with the redirect
307: temporary redirect, similar to 302, was forced to use POST method
400: request message grammar is wrong, the server can't identify
401: request requires authentication
403: request corresponding resource access are banned from
404: the server cannot find the corresponding resources
500: the server internal error
503: the server is busy


The Http protocol was first field

A, general first field (request message and response messages will use the first field)
Date: to create a message time
Connection: the Connection management
The cache-control: Cache Control
Transfer - Encoding: message transmission Encoding of
B, request header fields (request packet will use the first field)
Host: request to the server resources
Accept: can handle media type
The Accept - Charset: can receive character set
The Accept - Encoding: acceptable content Encoding
The Accept - Language: acceptable natural Language
C, the first response field (response packet will use the first field)
The Accept - Ranges: acceptable range of bytes
Location: the client redirect to the URI of the
Server: HTTP Server installation information
D, entity first field (request and response message message entity part USES the first field)
Allow: resources can support HTTP method
The content-type: the Type of entity main class
Content - Encoding: entity body applicable Encoding
The Content - Language: entity of natural Language
The Content - Length: entity of the number of bytes
Content - Range: the position of the entity subject Range, generally USES when part requests


11. Advantages and disadvantages of Http and Https?

(1). Use clear unencrypted communication, content can be tapped, that is, get caught analysis

(2). Don't verify communication party identity, may disguise

(3). Can't verify message integrity, may have been tampered with

Https is Http and encryption processing (typically SSL security communication lines) + certification, integrity protection


12. Http optimization

Using the load balancing optimization and accelerate the HTTP application

Using HTTP Cache to optimize website


What are the characteristics of 13. The Http protocol?

1, support the client/server mode; 2, simple and fast; 3, flexible; 4, no connection; 5, stateless;


14. The Cookie will be overwritten, localStorage will be overwritten

Cookies can be covered, if overwrite the cookies with the same name, will cover cookies before
If you want to delete a Cookie, you just need to create a new name of the Cookie, and putting the maxAge is set to 0, and added to the response to cover the original cookies, attention is 0 instead of negative, negative number represents the meaning of the other,

LocalStorage is stored in an object. A key/value pair
What is localStorage, in HTML 5, new joined a localStorage features, this feature is primarily used as local storage to use, solved the problem of the cookie storage space (cookies each cookie storage space for 4 k), general browser support in localStorage is 5 m size, the localStorage are different in different browsers,

The advantage of localStorage
1, localStorage expand the limit cookies 4 k
2, localStorage will first request data can be stored directly to the local, this is equivalent to the size of a 5 m on the front page of the database, compared to the cookie can save bandwidth, but this is only in the high version of the browser support
The limitations of localStorage
1, the size of the browser is not unified, and more than in IE8 version of Internet explorer to support localStorage this attribute
2, at present all the browser the localStorage type limit value of type string for this in our daily common JSON object types need some transformation
3, localStorage under browser privacy mode cannot be read
4, localStorage is essentially to read string, if the content is much consumes memory space, and can lead to a page change card
5, localStorage spiders crawling to
The only distinction localStorage and sessionStorage is localStorage belongs to the permanent storage, and sessionStorage belongs to when the end of the session, key/value pair will be cleared in the sessionStorage

  • Related