Table of Contents
A brief introduction to the HTTP protocol
URL
Request
Response
Status code
Request method
The difference between GET and POST
Home Web Front-end HTML Tutorial What is HTTP protocol

What is HTTP protocol

Sep 19, 2017 am 10:06 AM
http What protocol

A brief introduction to the HTTP protocol

The HTTP protocol is a hypertext transfer protocol, which is a communication protocol based on TCP/IP for data transmission

Features:
1. Simple and fast , when the client initiates a request to the server, it only needs to transmit the request method and path. Commonly used request methods include POST, GET, etc. Each method specifies a different type of contact between the client and the server. Because the HTTP protocol is simple, the communication speed is fast
2. Flexible: any type of data object can be transmitted. The transmission type is marked by Content-Type
3. No connection: Limit each connection to only process one request. After the server processes the client's request, it will disconnect after receiving the client's response
4. Stateless: HTTP is a stateless protocol. Stateless means that the protocol has no memory ability for transaction processing. The lack of status means that if the previous information is needed for subsequent processing, it must be retransmitted, which may increase the amount of data transmitted per connection. On the other hand, when the server does not need other information, its response will be very fast
5. Supports B/S and C/S modes

URL

URL is a uniform resource identifier used by HTTP to transmit data and establish connections. URL is a special type of URI, the full name is UniformResourceLocator, and the Chinese name is Uniform Resource Locator. The URL contains the following parts:
For example: https://baike.baidu.com:8080/item/url/110640 ?fr=aladdin
1. Protocol/mode part: It tells the browser how to handle the file to be opened. The most commonly used mode is the Hypertext Transfer Protocol (HTTP), which is used to access the Internet. Other protocols are as follows:
http——Hypertext Transfer Protocol resources
https - Hypertext Transfer Protocol delivered using Secure Sockets Layer
ftp——File Transfer Protocol
mailto——email address
ldap——Lightweight Directory Access Protocol Search
file - a file shared on a local computer or online
News——Usenet News Group
gopher——Gopher protocol
telnet——Telnet protocol
In the above example, the protocol part is https
2. Domain name part: The above domain name is: baike.baidu.com
3. Port part: What follows the domain name is is the port number. Use: to separate the port from the domain name. The port is not a necessary part of a URL. If the port number is omitted, the default port will be used
4. The file name part: /item/url/110640
5 . Parameter part: fr=aladdin, that is,

Request


after the question mark. The HTTP request message Request mainly consists of the following parts:
* Request line: Request method | URL | Protocol version
* Request header: The request header contains a lot of useful information about the client environment and the request body
* Request body: There is a blank line between the request header and the request body. This The line is very important, it indicates that the request header has ended, and what follows is the request body. The request body can contain query string information submitted by the customer

Response

HTTP response message Response consists of the following parts:
* Status line: Protocol version | Status code | Status Message
* Response header: Date, Content-Type, etc.
* Response text: Server-side return data

Status code

The status code consists of three digits, the first Numbers define the category of the response
* 1xx: Indication message, indicating that the request has been received, continue processing
* 2xx: Success, indicating that the request has been successfully received
* 3xx: Redirect, indicating that the request will be made at night Further operations are required
* 4xx: Client error, indicating that the request has a syntax error or cannot be implemented
* 5xx: Server error, indicating that the server failed to implement a legal request

Common status Code:

1

200 - ok - 请求成功400 - Bad Request - 客户端请求有语法错误,不能被服务器理解401 - Unauthorized - 请求未经授权403 - Forbidden - 服务器收到请求,但是拒绝提供服务404 - Not Found - 请求资源不存在500 - Internal Server Error - 内部服务器错误503 - Server Unavaliable - 服务器不可用

Copy after login

Request method

1

2

HTTP 1.0 定义了三种请求方法 :GET、POST、HEAD

HTTP 1.1 新增了五种请求方法 :OPTIONS、PUT、DELETE、TRACE、CONNECT

Copy after login

1

2

3

4

5

6

GET - 请求指定的页面信息,并返回实体主体

HEAD - 类似于GET请求,但是返回的只有报头

POST - 向指定的资源提交数据进行处理请求

PUT - 从客户端向服务器传送的数据取代指定文件的内容DELETE - 请求服务器删除指定的页面

CONNECT - HTTP/1.1协议中预留给能够将连接改为管道方式的代理服务器。OPTIONS - 允许客户端查看服务器性能

TRACE - 回显服务器收到的请求,主要用于测试或诊断。

Copy after login

The difference between GET and POST

  1. Data submission: GET request data will be placed after the URL, using & number to connect, but the POST request data will be placed in the HTTP packet

  2. Transmission data size: Since general browsers have restrictions on the length of the URL, GET is used to request the data There will be a size limit, but POST puts the data in the package, that is, there is no size limit

  3. Security: GET submits the data in the URL and can be cached to return the data

Note:
1. The HTTP protocol does not limit the size of transmitted data, and the HTTP protocol specification does not limit the length of the URL.
2. HTTP’s GET, POST, and SOAP protocols all run on http

(1) GET: The request parameters are appended to the URL as a sequence of key/value pairs (query string) The length of the
query string is limited by web browsers and web servers (such as IE supports up to 2048 characters), which is not suitable for transmitting large data sets. At the same time, it is very unsafe

(2) POST: The request parameters are transmitted in a different part of the http header (named entity body). This part is used to transmit form information, so Content-type must be set to: application/x-www- form-urlencoded. Post is designed to support user fields on web forms, and its parameters are also transmitted as key/value pairs.
But: it does not support complex data types because post does not define the semantics and rules for transmitting data structures.

(3) SOAP: It is a special version of http post, following a special xml message format
Content-type is set to: text/xml Any data can be xmlized.

The HTTP protocol defines many methods of interacting with the server, the most basic of which are GET, POST, PUT, and DELETE. A URL address is used to describe a resource on the network, and in HTTP GET, POST, PUT, and DELETE correspond to the four operations of checking, modifying, adding, and deleting this resource. Our most common ones are GET and POST. GET is generally used to obtain/query resource information, while POST is generally used to update resource information.

The above is the detailed content of What is HTTP protocol. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) Dec 31, 2023 pm 05:15 PM

How to set up keyboard startup on Gigabyte's motherboard. First, if it needs to support keyboard startup, it must be a PS2 keyboard! ! The setting steps are as follows: Step 1: Press Del or F2 to enter the BIOS after booting, and go to the Advanced (Advanced) mode of the BIOS. Ordinary motherboards enter the EZ (Easy) mode of the motherboard by default. You need to press F7 to switch to the Advanced mode. ROG series motherboards enter the BIOS by default. Advanced mode (we use Simplified Chinese to demonstrate) Step 2: Select to - [Advanced] - [Advanced Power Management (APM)] Step 3: Find the option [Wake up by PS2 keyboard] Step 4: This option The default is Disabled. After pulling down, you can see three different setting options, namely press [space bar] to turn on the computer, press group

What is the best graphics card for i7 3770? What is the best graphics card for i7 3770? Dec 29, 2023 am 09:12 AM

What graphics card is good for Core i73770? RTX3070 is a very powerful graphics card with excellent performance and advanced technology. Whether you're playing games, rendering graphics, or performing machine learning, the RTX3070 can handle it with ease. It uses NVIDIA's Ampere architecture, has 5888 CUDA cores and 8GB of GDDR6 memory, which can provide a smooth gaming experience and high-quality graphics effects. RTX3070 also supports ray tracing technology, which can present realistic light and shadow effects. All in all, the RTX3070 is a powerful and advanced graphics card suitable for those who pursue high performance and high quality. RTX3070 is an NVIDIA series graphics card. Powered by 2nd generation NVID

Understand common application scenarios of web page redirection and understand the HTTP 301 status code Understand common application scenarios of web page redirection and understand the HTTP 301 status code Feb 18, 2024 pm 08:41 PM

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

Choosing the right tablet for music students Choosing the right tablet for music students Jan 10, 2024 pm 10:09 PM

Which tablet is suitable for musicians? The 12.9-inch speaker in Huawei’s iPad is a very good product. It comes with four speakers and the sound is excellent. Moreover, it belongs to the pro series, which is slightly better than other styles. Overall, ipad pro is a very good product. The speaker of this mini4 mobile phone is small and the effect is average. It cannot be used to play music externally, you still need to rely on headphones to enjoy music. Headphones with good sound quality will have a slightly better effect, but cheap headphones worth thirty or forty yuan cannot meet the requirements. What tablet should I use for electronic piano music? If you want to buy an iPad larger than 10 inches, I recommend using two applications, namely Henle and Piascore. Provided by Henle

What is the function of cortana? What is the function of cortana? Jan 15, 2024 pm 10:15 PM

In the process of using the Windows 10 operating system developed by Microsoft, many users are curious and confused about the new technology called Cortana. Cortana's official name in the Chinese context is "Cortana", which is actually a built-in function of the Windows 10 system. Cortana, an artificial intelligence (AIassistant) service program. Frequently asked questions and solutions. How to open Cortana and not respond. Solution steps. Chinese solution is not supported. How to put the search box into Cortana. What software is Cortana? Answer: "Cortana" It is a cloud platform personal intelligent assistant carefully built by Microsoft. It has two usage modes: login and non-login. When you are logged in

Choose the driver version that suits your RX580 Choose the driver version that suits your RX580 Dec 29, 2023 pm 05:34 PM

What driver is good to install on rx5808g? 20.5.1 and 20.4.2WHQL refer to the version number of the software or driver. These version numbers are typically used to identify updates or fixes to software or drivers. In the computer world, WHQL stands for Windows Hardware Quality Labs, which is an institution used by Microsoft to test and verify the compliance and stability of hardware and drivers. Therefore, 20.5.1 and 20.4.2WHQL indicate that these software or drivers have passed Microsoft's testing and verification and can be safely used in the Windows operating system. AMDrx580 graphics card relatively stable drivers 20.5.1 and 20.4.2WHQL refers to the version number of the software or driver. These version numbers are passed

Which games are suitable for playing with i34150 and 1G independent graphics (which games is suitable for i34150) Which games are suitable for playing with i34150 and 1G independent graphics (which games is suitable for i34150) Jan 05, 2024 pm 08:24 PM

What games can be played with i34150 with 1G independent graphics? Can it play small games such as LoL? GTX750 and GTX750TI are very suitable graphics card choices. If you just play some small games or not play games, it is recommended to use the i34150 integrated graphics card. Generally speaking, the price difference between graphics cards and processors is not very big, so it is important to choose a reasonable combination. If you need 2G of video memory, it is recommended to choose GTX750TI; if you only need 1G of video memory, just choose GTX750. GTX750TI can be seen as an enhanced version of GTX750, with overclocking capabilities. Which graphics card can be paired with i34150 depends on your needs. If you plan to play stand-alone games, it is recommended that you consider changing the graphics card. you can choose

What configuration is required to run CAD smoothly? What configuration is required to run CAD smoothly? Jan 01, 2024 pm 07:17 PM

What configurations are needed to use CAD smoothly? To use CAD software smoothly, you need to meet the following configuration requirements: Processor requirements: In order to run "Word Play Flowers" smoothly, you need to be equipped with at least one Intel Corei5 or AMD Ryzen5 or above processor. Of course, if you choose a higher-performance processor, you'll be able to get faster processing speeds and better performance. Memory is a very important component in the computer. It has a direct impact on the performance and user experience of the computer. Generally speaking, we recommend at least 8GB of memory, which can meet the needs of most daily use. However, for better performance and smoother usage experience, it is recommended to choose a memory configuration of 16GB or above. This ensures that the

See all articles