Skip to content

HTTP (Hypertext Transfer Protocol) is the application-layer protocol that powers the World Wide Web. Originally designed for retrieving hypertext documents (RFC 1945, HTTP/1.0 in 1996), it has evolved Into a general-purpose application protocol used for APIs, streaming, IoT communication, and Virtually every client-server interaction on the Internet.

This section covers HTTP/1.1 (RFC 9112), HTTP/2 (RFC 9113), HTTP/3 (RFC 9114), and the practical Aspects of deploying and debugging HTTP-based services.

HTTP/1.1 (originally RFC 2616, now obsoleted by RFC 9110-9114) is the foundational version of HTTP. Despite being over 25 years old, it remains the most widely deployed version and is still the Default for many client-server interactions.

HTTP defines methods that indicate the desired action on a resource:

MethodIdempotentSafeCacheablePurpose
GETYesYesYesRetrieve a resource
HEADYesYesYesRetrieve headers only
POSTNoNoConditionalSubmit data for processing
PUTYesNoNoReplace a resource entirely
DELETEYesNoNoRemove a resource
PATCHNoNoNoPartial modification of a resource
OPTIONSYesYesNoDescribe communication options
TRACEYesYesNoLoop-back test (rarely used)
CONNECTNoNoNoEstablish a tunnel (e.g., TLS proxy)

Idempotent: Repeating the request produces the same result. PUT /users/1 with the same payload Creates or replaces user 1 — calling it multiple times has the same effect. POST /users creates a New user each time.

Safe: Does not modify server state. GET should never have side effects (though in practice, Many APIs violate this).

Terminal window
# HTTP methods with curl
curl -X GET https://api.example.com/users/1
curl -X POST -H "Content-Type: application/json" -d "{"name":"Alice"}' https://api.example.com/users
curl -X PUT -H "Content-Type: application/json" -d '{"name":"Alice Updated"}' https://api.example.com/users/1
curl -X DELETE https://api.example.com/users/1
curl -X PATCH -H "Content-Type: application/json" -d '{"name":"Bob"}' https://api.example.com/users/1
curl -X OPTIONS https://api.example.com/users
curl -X HEAD https://api.example.com/users/1

Status codes indicate the result of the request. They are grouped into five classes:

1xx — Informational:

CodeMeaningUse Case
100ContinueClient should send the request body
101Switching ProtocolsUpgrading to WebSocket or HTTP/2

2xx — Success:

CodeMeaningUse Case
200OKStandard success response
201CreatedResource created (POST/PUT)
204No ContentSuccess with no response body (DELETE)
206Partial ContentRange request (resumable downloads)

3xx — Redirection:

CodeMeaningUse Case
301Moved PermanentlyResource has a new permanent URL
302FoundTemporary redirect (method may change to GET)
303See OtherResponse is at another URI (method changes to GET)
304Not ModifiedCached version is still valid
307Temporary RedirectTemporary redirect (method preserved)
308Permanent RedirectPermanent redirect (method preserved)