HTTP protocol and HTTPS protocol

HTTP works


HTTP protocol defines how Web client-side requests a Web page from the Web server and the server how to transfer a Web page to the client. HTTP protocol uses a request / response model. The client sends the server a request packet, the method comprising the requested request packet, URL, protocol version, and requested data request header. A server response status line, including the contents of the protocol version response, success or error code, the server information, the response header and the response data.

The following is a step of HTTP request / response:

\ 1. The client connects to the Web server
a HTTP client, typically a browser, Web server with HTTP port (default is 80) to establish a TCP socket connection. For example, http://www.luffycity.com .

\ 2. HTTP request
sent by a TCP socket text, client request message to the Web server, a request packet by the request line, request headers, blank lines, and 4 parts request data.

\ 3. HTTP server accepts the request and returns the response to
the Web server parses request, locate the requested resource. The copy of the resource server writes a TCP socket, read by the client-side. A response line from the state, in response to the head, and blank lines in response to data 4 parts.

\ 4 releases the connection TCP connection.
If the connection mode is close, then the server closes a TCP connection, the client passive close the connection, the release of a TCP connection; if the connection mode keepalive, then the connection will remain for some time, during which time you can continue receiving a request;

\ 5. The client browser parses the HTML content
client browser status line resolved first, to see that the request is successful status code. Then parse each response header, the response header to inform the character set of HTML documents and document several bytes. The client browser reads the HTML response data, formatted according to its HTML syntax, and displayed in the browser window.

For example: Type the URL in the browser address bar, then press Enter to go through the following process:

  1. Browser request to the DNS server to resolve the domain name in the URL corresponding to IP addresses;
  2. After parsing the IP address of the TCP connection establishment according to the IP address and the default port 80, and the server;
  3. Issues a read file browser (URL domain name corresponding to the rear portion of the file) of the HTTP request, the request packet as a TCP three-way handshake packets of the third data to the server;
  4. The server responds to the browser request, and sends the html text corresponding to the browser;
  5. Release the TCP connection;
  6. Html text and the browser displays the contents; 

HTTP status code


All of the first row are HTTP response status line, followed by the current version of HTTP, three-digit status code, and a description of the state of phrases, each other separated by a space.

The first digit status code representing the type of the current response:

  • 1xx message - the server request has been received, processing continues
  • 2xx Success - server request has been received successfully, understood, and accepted
  • 3xx Redirection - Next Steps need to complete this request
  • Request 4xx error - request containing the lexical error or can not be executed
  • 5xx Server Error - Server error occurred while processing a request properly

img

There is a problem in general http:

  • Plaintext transmission request information, taken vulnerable to eavesdropping.
  • Check the integrity of data is not readily be tampered with.
  • Did not verify each other's identity, posing danger exists.

What browser uses HTTPS to transfer data is the process ?

  1. First client establishes an SSL connection through the URL to access the server.
  2. After the server receives a client request, the certificate information will be supported by the website (public key contained in the certificate) transmit a copy to the client.
  3. Client server security level began to negotiate SSL connection, which is encrypted information level.
  4. The client browser, depending on the security level agreed to establish a session key, and then use the site's public key to encrypt the session key and send it to the site.
  5. Server use their private key to decrypt the session key.
  6. Using the communication between the server session key encrypted with the client.

è¿éåå¾çæè¿ °

HTTPS shortcomings

  • HTTPS protocol to shake hands many times, resulting in page load time extended nearly 50%;
  • HTTP cache not as efficient HTTPS connection, increases data overhead and power consumption;
  • SSL certificates need to apply for the money, the more powerful the higher the cost of the certificate.
  • SSL security algorithms involved will consume CPU resources, large consumption of server resources.

Summed up the difference between HTTPS and HTTP

  • HTTPS is a secure version of HTTP protocol, HTTP data transmission protocol is a plain text, are unsafe, HTTPS uses SSL / TLS protocol is encrypted.
  • Use different http and https connections, the default port is not the same, http is 80, https is 443.

Go to:

HTTP:https://www.cnblogs.com/an-wen/p/11180076.html

HTTPS:

 

Published 25 original articles · won praise 6 · views 7543

Guess you like

Origin blog.csdn.net/B_G_boy/article/details/104659377