Introduction to http

Introduction to http


  • What is it?

    • Network communication protocol
      • Hyper Text Transfer Protocol --> Hyper Text Transfer Protocol
      • Scalable
        • Extensibility is shown in: transferring content, from the initial text, to the layout description, pictures, videos, scripts, etc.
        • Another level of scalability: the link can be a normal connection or an encrypted connection
  • effect:

    • Used for communication between web browser and web server
  • Features:

    • Typical client-server model

      • client-server protocol <client-server>
      • The client opens a link to make a request, and then waits until it receives a server-side response
    • Stateless protocol

      • Stateless does not refer to the status code of the server response, it means that no data is retained between two requests
      • The server will not retain any data between the two requests <status>

http component

  • client-proxy-caches-server
  • Client
    • User-agent is any tool that can initiate actions for users, mainly referring to the browser
    • Request
  • Web server
    • Response
  • Proxies
    • Cache <public, private>
    • Filter <anti-virus scanning, parental control>
    • Load balancing <let multiple servers serve different requests>
    • Authentication <authority management of different resources>
    • Log record <Allow to store historical information>

The basic nature of http

  • simple
    • The message is easy to understand, allowing simple testing
  • Scalable
    • The http headers appearing in http 1.0 can be set. If the server and client headers are the same, new functions can be extended
  • Stateless, with conversation
    • The two requests are unrelated and can be extended through the http header, and the last request information is added to the http header as a cookie to create a stateful session
  • Each http request will establish a TCP connection <so it takes time, takes up bandwidth, and wastes resources>
    • HTTP 1.1 can set the connection to change the connection to a long connection, change the connection method
    • http 2.0 changes the connection to a warm connection by reusing connection messages

What can http control

Common features that can be controlled by HTTP

  • Cache
    • The document caching method can be set via http
    • The server can inform the client of the cached files and the length of the cache
    • The client can also order documents cached by the intermediate proxy layer
  • Certification
    • You can set the access rights of the page
    • Set the specified session through http cookies
  • Open homologous restriction
  • Proxy and tunnel
  • Conversation

http stream

The process of initiating communication <information interaction> between the front and back ends

  • Open <reuse> a TCP connection
  • Send an http message
    • Before http 2, messages were semantically readable
    • The http 2 message is compressed and cannot be read directly, but the principle is the same
  • Read the message information returned by the server
  • Close the connection, or reuse the connection for subsequent services

http message

Regardless of whether it is a request or a response, the format is almost the same


  • method ----> GET
  • path ---->/
  • vsersion of the protocol ----> HTTP/1.1 <most http versions now are 1.1>
  • Headers ----> The rest are Headers, request header package information


  • vsersion of the protocol ----> HTTP/1.1
  • status code ----> Generally successful requests are 200
  • status message ----> OK
  • Headers ----> The rest are Headers, which respond to the information contained in the header