[Notes] [HTTP] HTTP Information in Chapter 3 of "Illustrated HTTP"

foreword

  • Where there is input, there must be output. This note is a summary of the knowledge involved in each chapter after I read "Graphic HTTP"
  • The blog will publish each chapter of the book as an article, and the next blog will be published at an uncertain time
  • Some of the notes in the notes have been sorted out after personal understanding, and there may be deviations. Readers are also kindly requested to help point out, thank you.

disclaimer

  • This blog is my notes after studying "Graphic HTTP", which is intended to facilitate review and review, not for commercial purposes.
  • For the sake of convenience, some pictures on the blog are consistent with those in the book, so I didn’t take screenshots by myself, but quoted the picture addresses of other people’s blogs, and thanked these bloggers for their picture beds.
  • This note is used to record my summary of this knowledge. To facilitate future work and study.
  • The content is not complete with the original book, please read it in conjunction with the original book
  • If there is any infringement, please inform and delete it immediately.

Chapter 3 HTTP Information in HTTP Messages

3.1 HTTP message

1. HTTP message

  • Information for HTTP protocol interaction

    • Request message: HTTP message at the requesting end (client)
    • Response message: the HTTP message of the responder (server)
  • itself is a string literal consisting of multiple lines of data

  • Message composition:

    • The structure of the request message header and the response message header

      field contains content
      request line The method used for the request, the request URI and the HTTP version
      status line Indicates the status code, reason phrase and HTTP version of the response result
      header field Various headers representing various conditions and attributes of requests and responses
      other HTTP RFC undefined headers (Cookie, etc.)

3.3 Encoding improves transmission rate

  • [Encoding] (# 2. Content encoding for compressed transmission) during transmission can effectively handle a large number of access requests
  • Will consume more CPU resources.

1. message bodyandentitydifference

message entity
1. It is the basic unit in HTTP communication
2. It is composed of octet sequence (octet sequence, where octet is 8 bits)
3. It is transmitted through HTTP communication
1. The payload data (supplementary item) is transmitted
as a request or response 2. The content consists of an entity header and an entity body
  • The body of the HTTP message is used to transmit the entity body of the request or response.
    • Usually: message body = entity body
    • When the encoding operation is performed during transmission: the content of the entity body changes, which causes it to differ from the message body.

2. Compressed transmissioncontent encoding

  • Indicates the encoding format applied to the entity content, and keeps the entity information compressed as it is.

  • The content-encoded entity is received by the client and is responsible for decoding it.

  • Commonly used content encodings

    content encoding express
    gzip GNU zip
    compress Standard compression for UNIX systems
    deflate zlib
    identity no encoding

3. Split sentchunked transfer encoding

  • The function of dividing the entity body into chunks

    • When transferring large-capacity data, by dividing the data into multiple blocks, the browser can display the page step by step.

      【step】

      1. Divide the entity body into multiple parts (blocks).
        • Each block will be marked with the block size in hexadecimal, and the last block of the entity body will be marked with "0(CR+LF)".
      2. Entity bodies encoded using chunked transfers will be decoded by the receiving client and restored to their pre-encoded entity bodies.

3.4 Sending a multipart object collection of various data

1. MIME mechanism

  • Function: When sending an email, you can write text in the email and add multiple files.

  • Allow mail to process text, pictures, videos and many different types of data.

  • Use the [multipart object collection](# 2. multipart object collection) method to accommodate multiple copies of different types of data.


2. Multipart object collection

multipart/form-data

  • Usage scenario: when uploading a web form file

  • Example:

multipart/byteranges

  • Usage scenario: When the status code 206 (Partial Content, partial content) response message contains multiple ranges of content

  • Example:

    • Notice
      • Use boundarystrings to demarcate the various types of entities specified by a collection of multipart objects.
      • inserts markers before the start line of each entityboundary specified by the string--
      • And at the end of the string corresponding to the multipart object collection, insert --the marker

3.5 Range requests to get partial content

1. Range Request

  • Request sent by specified range

    • [Applicable to] When the network is interrupted during the download process, you can use the range request without re-downloading, and the range request can resume the download from the previous download interruption.
  • Range specification format

    //1. 从起始数值-截止数值
    Range: bytes=起始数值-截止数值
    
    //2. 从起始数值之后的全部
    Range: bytes=起始数值-
    
    //3. 多重范围
    Range: bytes=起始数值1-截止数值1,起始数值2-截止数值2
    

    Notice】Multi-range range request, the response will return a response message after the header field is Content-Typemarkedmultipart/byteranges

  • Response returns

    • For range requests, the response will return 206 Partial Contenta response message with a status code.
    • If the server does not respond to the range request , return the status code 200 OK and the full entity content

3.6 Content negotiation returns the most suitable content

1. Content negotiation mechanism

  • The client and the server negotiate on the response resource content, and then provide the most suitable resource to the client.

    When the default language of the browser is English or Chinese, when accessing a web page with the same URI, the corresponding English or Chinese version of the web page will be displayed.

  • The language, character set, encoding method, etc. of the response resource are used as the basis for judgment.

  • Content Negotiation Technology Type

    technology type Negotiate position reference content
    Server-driven Negotiation server side Refer to the first field of the request
    Agent-driven Negotiation client _ 1. The user manually selects from a list of options displayed by the browser.
    2. The above selection can be made automatically on a Web page using JavaScript scripts .
    Transparent Negotiation Server-side and client-side

Guess you like

Origin blog.csdn.net/weixin_45944495/article/details/130572980