current position:Home>Explanation of HTTP network protocol

Explanation of HTTP network protocol

2022-06-24 08:55:13Software testing Xiaobai

HTTP Network protocol

What is? HTTP?

HTTP yes Hyper Text Transfer Protocol( Hypertext transfer protocol ) Abbreviation . It's based on TCP/IP Communication protocol to transmit data .

Simply speaking , It is a kind of agreement , An agreement between a client and a server .

What is an agreement ?

The language of communication between computers is called protocol , Different computers must use the same protocol to communicate .

HTTP Network communication process

HTTP The protocol works between the client and the server , The whole communication process , The browser acts as HTTP Client pass URL towards HTTP The server is WEB The server sends all requests ,Web According to the received request , Will send a response message to the client .

URL form :

1. The partial The URL Part of the agreement is “http:”, This means that the Web uses HTTP agreement . stay Internet A variety of protocols can be used in , Such as HTTP,FTP wait .

2. domain name /ip The URL The domain name section is, or :, They are both Baidu websites

3. Port part Following the domain name is the port , Use between domain name and port “:” As a separator . without , It means that URL The default port is used .

4. route From the first after the domain name “/” Let's go to the last one “/” until , It's the path part .

5. Parameters of the part from “?” Start to “#” The part in between is the parameter part , Also known as query parameters . Parameters can be allowed to have more than one parameter , Between parameters “&” As a separator .

HTTP message

The carrier of information transmission between client and server is called message , The message is divided into two parts: request and response .

Request message :

The process by which a client sends data to a server is called a request message

Format :

Request line : Include request method , The resources to visit and the HTTP edition

Request header : Describe additional information the server will use

Blank line : An empty line after the request message header is required

Request body :get There is often no requester ,post The request body contains the requested parameters

Request method :

GET: The request for Request-URI Identified resources .

POST: stay Request-URI New data is appended to the identified resource .

HEAD: Request to get by Request-URI The response header of the identified resource .

PUT: Request the server to store a resource , And use Request-URI As its logo .

DELETE: Request server delete Request-URI Identified resources .

TRACE: The request server sends back the received request information , Mainly used for testing or diagnosis .

CONNECT: Keep it for future use .

OPTIONS: Request query server performance , Or Query options and requirements related to resources .

The common request method in practical application is GET and POST.

GET and POST The difference between :

1. From the perspective of parameter passing :GET The requested parameters are spliced directly into the address bar URL Behind , and POST The request parameters are placed in the request body .

2. In terms of length limitation :GET The request has a specific length limit , Generally not more than 1024KB, and POST In theory, there is no , But browsers generally have a boundary .

3. In terms of security :GET Request compared to POST, Because the data is displayed in clear text URL above , So security and privacy are not as good as POST.

4. In terms of function ,GET Get data from the server ,POST Is to send data to the server .

response message :

Format :

1. Response line ( Status line ): Protocol version , Status code , Success and failure status information .

2. Response head : It consists of some key value pairs , It is used to describe some additional information to be used by the client .

3. Blank line : An empty line after the response header is required .

4. The response data ( Response Content ): The data and other information returned by the server to the client .

Status code and classification

When visitors visit a web page , The browser will send a request to the server where the web page is located . Before the browser receives and displays the web page , The server on which this page is located will return an include HTTP The header of the status code is used to respond to the browser's request .

Common status code categories

https and http What's the difference?

https yes http Security version of , Also known as hypertext secure transmission ,https It is a channel with encrypted transmission protocol , also SSL Provides the basis for secure encryption ,https Mainly for http The transmission of , And in HTTP And TCP There is a special encryption between / Authentication .

port :https The port of is 443, and http The port of is 80, Of course, the connection mode of the two is also different .

To transmit data :http The transmission is plaintext , and https Yes, it is ssl Encrypted ,https It's safe .

Apply for a certificate :https Transmission generally requires application for certificate , There may be a fee for applying for a certificate , and http Unwanted .


copyright notice
author[Software testing Xiaobai],Please bring the original link to reprint, thank you.

Random recommended