HTTP protocol is the Hypertext Transfer Protocol, which is mainly used to transfer hypertext from the server to the local browser. It consists of four parts: request line, request header, blank line and request data.
HTTP request message is divided into four parts: request line, request header, blank line and request data. Next, these four parts will be introduced in detail in the article, which has certain reference value and I hope it will be helpful to everyone.
[Recommended course: HTTP course]
Introduction to HTTP
HTTP protocol is the abbreviation of Hyper Text Transfer Protocol, which is a transfer protocol used to transfer hypertext from the World Wide Web server to the local browser.
It is a communication protocol based on TCP/IP to transmit data
HTTP working principle
(1) HTTP is connectionless: connectionless refers to Limit each connection to only one request. That is, after the server processes the user's request and receives the user's response, it disconnects the connection. This saves transmission time.
(2) HTTP is media independent: As long as the client and server know how to process the data content, any type of data can be sent through HTTP. Clients and servers specify the appropriate MIME-type content type to use.
(3) HTTP is stateless: The HTTP protocol is a stateless protocol. A stateless protocol means that it has no memory for transaction processing. If subsequent processing requires the previous information, it must be retransmitted, which results in an increase in the amount of data transmitted per connection. But there is also an advantage that when the server does not need the previous information, its response is faster
HTTP composition
Request line:
The request line consists of three parts: the request method field, the URL field and the HTTP protocol version, which are separated by spaces. For example,
GET /index.html HTTP/1.1
request method defines a total of 8 methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE, but the most commonly used methods are the GET method and the POST method, because currently most Most browsers only support GET and POST methods
Request header:
The request header is composed of keyword/value pairs, one pair per line, key Words and values are separated by English colon ":". Request headers inform the server about the client's request.
Typical request headers are:
User-Agent: the browser type that generated the request
Accept: a list of content types recognized by the client
Host: The requested host name, allowing multiple domain names to be at the same IP address, that is, a virtual host.
Example:
Host: localhost
Empty line
After the last request header is an empty line, send carriage return and line feed characters, and notify the server of the following No more request headers
Request data
The request data is not used in the GET method, but in the POST method. The POST method is suitable for situations where customers are required to fill out a form.
The most commonly used request headers related to request data are Content-Type and Content-Length.
Example:
Content-Type: application/json;charset=utf-8
Summary: The above is the entire content of this article, I hope it will be helpful to everyone learning http
The above is the detailed content of Detailed explanation of HTTP protocol. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.