search
HomeCommon ProblemWhat is the difference between post and get requests?

What is the difference between post and get requests?

Feb 03, 2023 am 11:23 AM
post requestget request

Difference: 1. Post request is more secure; post request will not be used as part of the URL, will not be cached, saved in server logs, and browser browsing records. If the get request is a static resource, it will Cache, if it is data, it will not be cached. 2. The data sent by the post request is larger, and the get request has a URL length limit. 3. The post request can send more data types, while the get request can only send ASCII characters. 4. The methods of parameter transmission are different. 5. Get generates one TCP packet; post generates two.

What is the difference between post and get requests?

The operating environment of this tutorial: Windows 10 system, Dell G3 computer.

Get request: Request data from a specified resource, used to obtain data, generally used for operations such as search sorting and filtering.

Post request: Submit the data to be processed to the specified resource, used to send the data to the server, generally used to modify and write data.

Get requests and post requests are essentially TCP links and there is no difference. However, due to HTTP regulations and browser/server limitations, they show some differences in the application process.

The difference between post request and get request

(1) post request is more secure (will not be part of the url and will not be cached) , saved in server logs and browser browsing records. If the get request is a static resource, it will be cached. If it is data, it will not be cached.)

(2) The data sent by the post request is larger ( The get request has a URL length limit, the http protocol itself does not limit the request length limit is determined and set by the browser and web server)

(3) The post request can send more data types (get requests can only Send ASCII characters)

(4) The parameter passing methods are different (get request parameters are passed through the url, and the post request is passed in the request body)

(5) The get request generates a TCP packet ; Post request generates two TCP data packets (get request, the browser will send the http header and data together, the server responds with 200 to return the data; post request, the browser sends the header first, the server responds with 100 continue, and the browser then sends data, the server responds with 200 and returns data)

Note: There is no Expect header when sending POST, and the server will naturally not send 100 continue.

Post request process:

(1) The browser requests a tcp connection (first handshake)

( 2) The server agrees to make a TCP connection (the second handshake)

(3) The browser confirms and sends the post request header (the third handshake, this message is relatively small, so http will be processed at this time First data sending)

(4) The server returns 100 Continue response

(5) The browser sends data

(6) The server returns 200 OK response

Get request process:

(1) Browser requests tcp connection (first handshake)

(2) Server Agree to TCP connection (second handshake)

(3) The browser confirms and sends the get request header and data (the third handshake, this message is relatively small, so http will perform the third handshake at this time One data transmission)

(4) The server returns a 200 OK response

If the network environment is good, the difference in time between sending a packet once and sending two packets can basically be ignored. In the case of poor network environment, TCP with two packets has great advantages in verifying the integrity of data packets.

For more related knowledge, please visit the FAQ column!

The above is the detailed content of What is the difference between post and get requests?. For more information, please follow other related articles on the PHP Chinese website!

Statement
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 Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MinGW - Minimalist GNU for Windows

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.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment