HTTP Common face Questions

Source: Internet
Author: User
Tags character set http request relative requires valid ssl certificate port number
the difference between HTTP and https:The difference between HTTP and https: The URL of HTTP starts with//HTTP, and the URL of HTTPS is not safe to start with https://, while HTTPS is a secure HTTP standard port of 80, while the standard port for HTTPS is 443 on the OSI In the network model, HTTP works on the application layer, while HTTPS's secure transport mechanism works at the transport layer where HTTP cannot be encrypted, while HTTPS encrypts the transmitted data for HTTP without a certificate, and HTTPS requires the issuing SSL certificate of the CA authority wosign what is the HTTP protocol stateless protocol? How to resolve the HTTP protocol stateless protocol?

A stateless protocol has no memory capability for transactional processing . a lack of state means that the previous information is required for subsequent processing That is , when the client sends an HTTP request again after an HTTP request is completed, HTTP does not know that the current client is an "old user". a cookie can be used to solve a stateless problem, a cookie is a pass, a cookie is sent to the client on the first visit, and when the client comes back with a cookie (pass), the server knows it is an "old user". difference between URI and URL for URI and URL

The URI, which is the Uniform Resource identifier, is the Uniform Resource identifier used to uniquely identify a resource. every resource available on the Web, such as HTML documents, images, video clips, programs, and so on, is a URI to locate URIs generally composed of three parts: ① access to the resource naming mechanism ② the host name of the resource ③ the name of the resource itself, represented by the path, with emphasis on resources.

The URL is the Uniform Resource Locator, a Uniform Resource locator, which is a specific URI that the URL can use to identify a resource and also how to locate the resource. URLs are strings used on the Internet to describe information resources, mainly used in various WWW client programs and server programs, especially the famous mosaic. URLs can be used in a unified format to describe various information resources, including files, server addresses and directories. URLs typically consist of three parts: the ① protocol (or service mode) ② the host IP address (and sometimes the port number) that holds the resource ③ the specific address of the host resource. such as directory and file name, etc.

Urn,uniform Resource Name, unified resource naming, identifies resources by name, such as mailto:java-net@java.sun.com. URIs define a Uniform resource identity in an abstract, high-level concept, whereas URLs and urns are the exact way the resource is identified. URLs and urns are all a kind of URI. Generally speaking, each URL is a URI, but not necessarily every URI is a URL. This is because the URI also includes a subclass, the Uniform Resource Name (URN), which names the resource but does not specify how to locate the resource. The mailto, News, and ISBN URIs above are examples of urns.

In the Java URI, a URI instance can represent absolute or relative, as long as it conforms to the syntax rules of the URI. The URL class not only conforms to semantics, but also contains information that locates the resource, so it cannot be relative.

In the Java class Library, the URI class does not contain any method of accessing the resource, its only function is parsing.

instead, the URL class can open a stream that reaches the resource. What are the common HTTP methods? what are the common HTTP methods? Get: Used to request access to a resource that has been identified by a URI (Uniform Resource Identifier), which can be passed to the server via a URL: Used to transfer 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. HTTP request message and Response message format HTTP request message and Response message format

The request message consists of four parts:


A, request line: Contains the request method, URI, HTTP version information B, request header field C, Request content entity D, blank line

The response message consists of four parts:


A, status line: Contains the HTTP version, the status code, the status code reason phrase B, the response header field C, the response content entity D, the blank line

A common header:

Generic Header field (header field used for request and response messages) Date: Create message Time Connection: Connection management Cache-control: Cached control transfer-encoding: Transmission encoding method of message body

Request Header field (header field to be used for request message) 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

Response Header field (the header field used by the response message) Accept-ranges: Acceptable byte range Location: URI to redirect client to Server:http server installation information

Entity Header field (header field used by the entity portion of the request message and the response message) Allow: A resource-supported HTTP method Content-type: The type of the 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 body Content-range: The location range of the entity body, typically used to emit partial requests using HTTPS works HTTPS works first, the HTTP request server to generate the certificate, The client verifies the validity and legality of the certificate, whether the domain name is consistent with the requested domain name, the public key of the certificate (RSA encryption), and so on; second, if the client passes the verification, the random number is generated according to the valid public key of the certificate, and the random number is encrypted with the public key (RSA encryption); The Digest of the MD5 (or SHA1) algorithm encryption, the RSA signature is obtained at this time, four, sent to the server, at this time only the server (RSA private key) can be decrypted. Five, decrypt the resulting random number, and then AES encryption, as the key (at this time the key only the client and the server know).

Specific reference links: http://blog.csdn.net/sean_cd/article/details/6966130 a complete HTTP request takes 7 steps through the 7 steps of a complete HTTP request

The HTTP communication mechanism is that during a complete HTTP communication, the following 7 steps will be completed between the Web browser and the Web server: establishing a TCP connection

Before HTTP work begins, the Web browser first establishes a connection to the Web server over the network, which is done through TCP, which works with the IP protocol to build the Internet, known as the TCP/IP protocol family, so the internet is also known as a TCP/IP network. HTTP is a higher level of application-level protocol than TCP, according to the rules, only the lower layer protocol is established before the protocol can be more connected, so the first to establish a TCP connection, the port number of the general TCP connection is 80. Web browser sends a request line to the Web server

Once a TCP connection is established, theWeb browser sends a request command to the Web server . For example: get/sample/hello.jsp http/1.1.

After the Web browser sends the request header browser to send its request command, it also sends some other information to the Web server in the form of header information, and then the browser sends a blank line to notify the server that it has ended sending the header information.

After the Web server answers the client to make a request to the server, the server responds back to the client, http/1.1, and the first part of the answer is the version number of the protocol and the response status code.

The Web server sends an answer header just as the client sends information about itself along with the request, the server also sends the user with the answer about its own data and the requested document.

After the Web server sends a data Web server to the browser to send header information to the browser, it sends a blank line to indicate that the header information is sent to the end, and then it sends the actual data requested by the user in the format described in the Content-type reply header information .

A Web server shuts down a TCP connection in general, once the Web server sends the request data to the browser, it closes the TCP connection, and then if the browser or server joins this line of code in its header information:

Connection:keep-alive

The TCP connection remains open after it is sent, so the browser can continue to send requests through the same connection. Maintaining a connection saves the time it takes to establish a new connection for each request and also saves network bandwidth.

Set up TCP connection, send request line, send request header--(arrival server) Send response header--Send response data--Break TCP connection

Most specific HTTP request procedure: http://blog.51cto.com/linux5588/1351007 Common HTTP corresponding status Code common HTTP corresponding status code 200: request is handled normally 204: The request is accepted but no resources can return 206: The client is only 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 REDIRECT 302: Temporary redirect 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: When a request with an attached condition is sent, it is returned when the condition is not met, regardless of redirection 307: Temporary redirect, similar to 302, just mandatory use of POST Method 400: Request message Syntax error, server unrecognized 401: request requires authentication 403: The requested resource is forbidden to access 404: The server cannot find the corresponding resource 500: Server Internal Error 503: Server busy HTTP1.1 version new feature HTTP1.1 version new feature A, the default persistent connection to save traffic , as long as the client service side of either end does not explicitly ask to disconnect the TCP connection, has remained connected, You can send multiple HTTP requests B, pipelining, and clients can make more than one HTTP request at a time without waiting for a response

C, the continuation of the breakpoint is actually the use of the HTTP message header using chunked transmission encoding, the entity body block transmission. http Optimization Scenarios

Let me briefly summarize the following: TCP multiplexing: TCP connection multiplexing is the reuse of HTTP requests from multiple clients to a single server-side TCP connection, while HTTP multiplexing is the process of multiple HTTP requests by one client over a TCP connection. The former is a unique feature of the load balancer device, which is a new feature supported by the HTTP 1.1 protocol and is currently supported by most browsers. Content Caching: Caches the content that is often used, so that the client can get the corresponding data directly in memory. Compression: Compress text data to reduce bandwidth SSL Acceleration (SSL acceleration): Encrypts the HTTP protocol using the SSL protocol, encrypts and accelerates within the channel TCP buffering: By adopting TCP buffering technology, the server-side response time and processing efficiency can be improved, and the connection burden to the server caused by the communication link problem is reduced.

Detailed reference:

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.