Version | Features |
---|---|
HTTP/1.1 | Keep-Alive, header-based multiplexing |
HTTP/2 | Binary protocol, multiplexing, server push |
HTTP/3 | Built on QUIC, low-latency, encrypted by default |
Feature | HTTP | HTTPS |
---|---|---|
Security | Unencrypted | Encrypted via TLS/SSL |
Port | 80 | 443 |
Data Protection | None | Prevents MITM & sniffing |
Header | Purpose | Used In | Example |
---|---|---|---|
Content-Type |
Specifies media type | Both | application/json |
Authorization |
Auth token for protected routes | Request | Bearer token123 |
Accept |
Desired response format | Request | application/json |
User-Agent |
Client information | Request | Mozilla/5.0 |
Cache-Control |
Caching behavior | Both | no-cache, max-age=3600 |
Set-Cookie |
Sends cookie to client | Response | Set-Cookie: session=abc123 |
Content-Length |
Indicates body size in bytes | Response | Content-Length: 128 |
Content Type | MIME Example |
---|---|
JSON | application/json |
HTML | text/html |
PNG Image | image/png |
application/pdf |
Request Line – Contains method, URL, and HTTP version
Example: GET /api/users HTTP/1.1
Headers – Key-value pairs providing metadata
Example: User-Agent: Mozilla/5.0
, Accept: application/json
Body – Optional payload, present in POST
, PUT
, PATCH
requests
Format: usually JSON, form data, or binary
GET /api/users HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
Accept: application/json
---
POST /api/users HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: 43
{
"name": "John",
"email": "[email protected]"
}
Component | Description |
---|---|
Method | GET , POST , PUT , DELETE , etc. |
URL | Target endpoint, e.g., /api/users |
HTTP Version | e.g., HTTP/1.1 , HTTP/2 , HTTP/3 |
Headers | Metadata about the request |
Body | Present in methods like POST , PUT |
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 123
{
"id": 1,
"name": "John Doe"
}
Component | Description |
---|---|
Status Code | Result of the request, e.g., 200 OK |
Headers | Metadata about the response |
Body | Optional data returned from the server |
Strong Caching