Fundamentals 10 min read

Understanding GET vs POST: HTTP Request Methods Explained with Real Examples

This article explains the structure of HTTP request messages, compares the characteristics of GET and POST methods, and provides real-world examples to illustrate how each method works and differs in practice.

Open Source Linux
Open Source Linux
Open Source Linux
Understanding GET vs POST: HTTP Request Methods Explained with Real Examples

Overview

This article summarizes HTTP request methods, focusing on GET and POST, their characteristics, request message structure, and differences.

HTTP Request Message

HTTP defines eight request methods: GET, POST, HEAD, PUT, DELETE, TRACE, CONNECT, and OPTIONS. The request message consists of three parts: request line, request headers, and request body.

Request line : method, URL, and HTTP version, with required spaces and CRLF.

Request headers : zero or more header fields, each formatted as "Name: Value" and terminated by CRLF.

Request body : present for methods like POST; empty for GET.

Example of a GET request to https://api.github.com/search/users?q=JakeWharton captured via packet sniffing:

GET /search/users?q=JakeWharton HTTP/1.1
Host: api.github.com
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: _octo=... (truncated)

The request line shows method GET, URL path, and HTTP/1.1 version. All following lines are headers; there is no request body.

Example of a POST request:

POST / HTTP/1.1
Host: www.wrox.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 40
Connection: Keep-Alive

name=Professional%20Ajax&publisher=Wiley

The POST request includes a request body with form data, separated from headers by an empty line.

Characteristics of GET

Parameters are placed in the URL after a “?” and separated by “&”.

Designed for safe and idempotent data retrieval.

Often cached by browsers.

URL length may be limited by browsers or servers.

Typically sends a single TCP packet.

Characteristics of POST

Used to modify server resources (e.g., submitting a like).

Not safe nor idempotent.

Parameters are sent in the request body, without length limit.

Usually involves two TCP packets (headers then body).

GET vs POST

Both are HTTP methods built on TCP; the protocol distinguishes them to manage requests differently. While technically you could send data with GET in the body or with POST in the URL, such usage may not be supported by servers.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

HTTPrequest methodsgetPOSTweb fundamentals
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.