HTTP

  • Hyper Text Transfer Protocol Hyper Text Transfer Protocol
  • The application layer

HTTPS

  • Hyper Text Transfer Protocol over SecureSocket Layer
  • HTTPS = HTTP + SSL

HTTP Version

Main features of HTTP

  1. Support client, server mode: request-response model
  2. Simple and fast: When requesting a service, only the request method and path need to be passed
  3. Flexible: Allows transfer of data objects of any type
  4. None connection: Only one request can be processed at a time. The server disconnects after the request is processed, saving resources
  5. Stateless: Does not retain information about all previous request or response packets and has no memory for transaction processing

HTTP request workflow

HTTP request methods

HTTP message structure

Example:

Header fields

General head domain describe
Connection The type of connection that the browser wants to use preferentially for HTTP communication: keep-alive close (open and close persistent connections)
Cache-Control Control the cache behavior: no-cache (forcing the server to verify again), no-store (not doing any caching), max-age=111111 (maximum time for caching resources in seconds), public (both client and proxy servers can use caching), private (proxy servers can not use caching)
Date Time of packet Creation
Pragma It is only used for request messages. The client requests that the intermediate server not return cached resources
Via Information about the proxy server is added to each proxy server and is separated by commas
Transfer-Encoding Transmission encoding: chunked block transmission
Upgrade The Upgrade protocol used by the client must be websocket together with Connection: Upgrade
Warning Warnings about cache-related issues
Request header field describe
Accept Media types that the client can receive correctly: Application/JSON text/plain
Accept-Charset Acceptable character set: Unicode-1-1
Accept-Encoding List of acceptable encoding formats: gzip Deflate
Accept-Language List of languages that can be correctly received: zh-cn,zh; 1 = 0.9, en, 1 = 0.8
Authorization Client authentication information: Bearer dSdSdFFlsfdjasd123, generally used for token storage
If-Match If-mach: “123456, compared with the server file flag
If-Modified-Since Local resource unmodified returns 304 (comparison time)
If-None-Match Local resource unmodified returns 304 (comparison mark)
User-Agent Client information, often used to identify the browser used by the client
Max-Forwards Limit the number of times that can be forwarded by proxy and gateway
Proxy-Authorization Sends authentication information to the proxy server
Range Request a portion of something, used with if-range
Referer The original URITE transport encoding of the request originating page, often used to prevent leasings and malicious requests
Response headers describe
Accept-Ranges Tells the client whether the server can accept range requests, bytes or None
Age The amount of time a resource exists in the proxy cache
ETag Resource identification, which changes when the resource changes
Location The client redirects to a URL
Proxy-Authenticate Sends authentication information to the proxy server
Server Server name: Apache Nginx
WWW-Authenticate Obtain the authentication scheme required by resources
Set-Cookie The client information is used to identify users
Entity header fields describe
Allow The correct way to request resources is GET HEAD POST
Content-Encoding Content encoding format: gzip Deflate
Content-Language Content In the language: zh-CN
Content-Length Request Body length (i.e. size of entity body) :
Content-Location Alternate address to return data
Content-MD5 MD5 check value of content in Base64 encryption format
Content-Range The content scope of the response body
Content-Type The media type of the content (e.g. ‘application/json; Charset = utF-8 ‘;
Expires The expiration time of the content
Last_modified When the content was last modified
Extension header fields describe
Cookie Sends the value of the Cookie to the server
Set-Cookie Sets the Cookie associated with the page
Refresh The browser refreshes the document after a specified period of time or jumps to a specified location
Content-Disposition Description of a downloadable resource by the server
# HTTP status code