HTTP network communication protocol

 

table of Contents


 Reserve knowledge

HTPPBefore explaining the protocol, first understand some basic computer network related knowledge

1.1 Computer network architecture

  • Define 
    each layer of the computer network + its set of protocols

  • The role
    defines the functions  that the computer network can perform

  • Structure Introduction 
    Computer network architecture is divided into 3 types: OSIarchitecture, TCP /  IParchitecture, five-tier architecture

    • OSIArchitecture: clear concept & complete concept, but complex & impractical

    • TCP /  IPArchitecture: Contains a series of network protocols that form the basis of the Internet, is Internetthe core protocol & is widely used in local area networks and wide area networks

    • Five-tier architecture: The architecture that combines OSI and  TCP /  IPis designed to learn & explain the principles of computers

  • TCP / IPThe architecture of is introduced in detail 
    because  TCP /  IParchitecture is more extensive, so the main explanation 

1.2 The basic model of HTTP protocol communication

  • HTTPThe basis of protocol transmission information: TCP/IPprotocol model 

  • HTTPThe protocol belongs to the highest application layer


 Introduction

Below, I will briefly introduce HTTP


Way of working

  • HTTPThe protocol uses a request / response working method

  • The specific workflow is as follows:


Detailed HTTP message

  • HTTPWays to interact with data at the application layer = message

  • HTTPThe message is divided into: request message & response message 

    Used to send requests & respond to requests, respectively
  • Below, the two types of messages will be introduced in detail

4.1 Request message

4.1.1 Message structure

  • HTTPThe request message consists of request line, request header & request body, as shown in the figure below

  • Below, each component will be described in detail

4.1.2 Detailed structure introduction

Composition 1: request line
  • Function 
    declaration request method, host domain name, resource path & protocol version


  • Composition of structure  request line = request method + request path + protocol version

    Note: Spaces cannot be saved

  • Composition Introduction

The difference between GET and PSOT methods is specifically explained here:

  • Example 
    design: request message adopting GETmethod,  URLaddress = http://www.tsinghua.edu.cn/chn/yxsz/index.htm; HTTP1.1version

The request line is:GET /chn/yxsz/index.htm HTTP/1.1

Composition 2: Request header
  • Function: declare some information of client, server / message

  • How to use: Use "header (field name): value (value)"

  • Common request headers
    1. Common headers for  request and response messages

2. Common Request Header

  • Example: 
    (URL address: http://www.tsinghua.edu.cn/chn/yxsz/index.htm) 
    Host: www.tsinghua.edu.cn (indicating host domain name) 
    User-Agent: Mozilla / 5.0 (indicating user Agent is using Netscape browser)

Composition 3: Request body
  • Role: to store the data information to be sent to the server

    Optional part, if  GET请求no data is requested

  • Usage: 3 kinds in total

So far, the request line, request header, and request body of the request message are all explained.

4.1.3 Summary

  • The summary of the request message is as follows

  • Request message example

4.2 HTTP response message

4.2.1 Message structure

  • HTTPResponse message includes: status line, response header & response body

  • Among them, the response header and response body are similar to the request header and request body of the request packet

  • The biggest difference between these two types of messages is the status line & request line

Below, each component will be described in detail

4.2.2 Detailed structure introduction

Composition 1: Status line

  • Function 
    statement protocol version, status code, status code description

  • The composition
    status line is composed  of protocol version, status code & status information 

    Among them, spaces cannot be saved


  • Specific introduction 

  • Status line example 
    HTTP/1.1 202 Accepted(accepted), HTTP/1.1 404 Not Found(not found)

Composition 2: Response header

  • Function: declare some information of client, server / message

  • How to use: Use "header (field name): value (value)"

  • Common request headers
    1. Common headers for  request and response messages

2. Common Response Header

Composition 3: Response body

  • Role: store the data information that needs to be returned to the client

  • Usage: It is consistent with the request body, and is also divided into: any type of data exchange format, key-value pair form and partial form

4.2.3 Summary of response messages

4.3 Summary

Below, a brief summary of the two message structures 


Additional knowledge

The following will explain some HTTPadditional knowledge:

  • HTTP1.1 With  HTTP1.0 distinction

  • HTTP With  HTTPSdistinction

  • HTTP Ways to handle long connections

5.1 Differences between HTTP1.1 and HTTP1.0

Http1.1 Compared  Http1.0 with the following advantages:

  • Introduce persistent connections, that is TCP, multiple HTTPrequests & responses can be transmitted in the same connection

  • Multiple requests & responses can be performed simultaneously and can be overlapped

  • Introduce more request headers & response headers 

 

No fields such as those related to authentication, state management &  Cachecaching, etc.HTTP1.0host

5.2 The difference between HTTP and HTTPS

5.3 How HTTP handles long connections

Guess you like

Origin www.cnblogs.com/21-Gram/p/12718515.html