176 lines
6.7 KiB
Plaintext
176 lines
6.7 KiB
Plaintext
|
|
HTTP Request
|
||
|
|
├── Request Line
|
||
|
|
│ ├── Method
|
||
|
|
│ │ ├── GET
|
||
|
|
│ │ ├── POST
|
||
|
|
│ │ ├── PUT
|
||
|
|
│ │ ├── PATCH
|
||
|
|
│ │ ├── DELETE
|
||
|
|
│ │ ├── HEAD
|
||
|
|
│ │ ├── OPTIONS
|
||
|
|
│ │ └── TRACE
|
||
|
|
│ ├── Request Target
|
||
|
|
│ │ ├── Absolute Path (/users/123)
|
||
|
|
│ │ ├── Path Parameters (/users/{id})
|
||
|
|
│ │ └── Query Parameters (?limit=10&sort=asc)
|
||
|
|
│ └── HTTP Version
|
||
|
|
│ ├── HTTP/1.0
|
||
|
|
│ ├── HTTP/1.1
|
||
|
|
│ ├── HTTP/2
|
||
|
|
│ └── HTTP/3 (QUIC, UDP-based)
|
||
|
|
│
|
||
|
|
├── Headers
|
||
|
|
│ ├── General Headers (apply to both request & response)
|
||
|
|
│ │ ├── Cache-Control
|
||
|
|
│ │ ├── Connection
|
||
|
|
│ │ ├── Date
|
||
|
|
│ │ ├── Pragma
|
||
|
|
│ │ ├── Trailer
|
||
|
|
│ │ ├── Transfer-Encoding
|
||
|
|
│ │ ├── Upgrade
|
||
|
|
│ │ └── Via
|
||
|
|
│ │
|
||
|
|
│ ├── Request-Specific Headers
|
||
|
|
│ │ ├── Host (required in HTTP/1.1)
|
||
|
|
│ │ ├── User-Agent
|
||
|
|
│ │ ├── Referer (now spelled `Referrer` in Fetch API)
|
||
|
|
│ │ ├── Origin
|
||
|
|
│ │ ├── Authorization
|
||
|
|
│ │ ├── Cookie
|
||
|
|
│ │ └── Proxy-Authorization
|
||
|
|
│ │
|
||
|
|
│ ├── Representation Headers (describe message body)
|
||
|
|
│ │ ├── Content-Type
|
||
|
|
│ │ ├── Content-Encoding
|
||
|
|
│ │ ├── Content-Language
|
||
|
|
│ │ ├── Content-Length
|
||
|
|
│ │ ├── Content-Location
|
||
|
|
│ │ └── Content-MD5 (deprecated)
|
||
|
|
│ │
|
||
|
|
│ ├── Conditional Headers (for caching & state validation)
|
||
|
|
│ │ ├── If-Match
|
||
|
|
│ │ ├── If-None-Match
|
||
|
|
│ │ ├── If-Modified-Since
|
||
|
|
│ │ ├── If-Unmodified-Since
|
||
|
|
│ │ └── If-Range
|
||
|
|
│ │
|
||
|
|
│ ├── Range Headers
|
||
|
|
│ │ ├── Range
|
||
|
|
│ │ └── If-Range
|
||
|
|
│ │
|
||
|
|
│ └── Custom Headers
|
||
|
|
│ └── X-* (e.g., X-Request-ID)
|
||
|
|
│
|
||
|
|
└── Body / Payload (optional)
|
||
|
|
├── Form submissions
|
||
|
|
│ ├── application/x-www-form-urlencoded
|
||
|
|
│ └── multipart/form-data
|
||
|
|
├── JSON (application/json)
|
||
|
|
├── XML (application/xml)
|
||
|
|
├── Plain text (text/plain)
|
||
|
|
├── Binary (images, files)
|
||
|
|
└── GraphQL / other APIs
|
||
|
|
|
||
|
|
|
||
|
|
---------------------------------------------------------------------------------------------------------------
|
||
|
|
===============================================================================================================
|
||
|
|
---------------------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
|
||
|
|
HTTP Response
|
||
|
|
├── Status Line
|
||
|
|
│ ├── HTTP Version (HTTP/1.1, HTTP/2, HTTP/3)
|
||
|
|
│ ├── Status Code
|
||
|
|
│ │ ├── 1xx Informational
|
||
|
|
│ │ │ ├── 100 Continue
|
||
|
|
│ │ │ ├── 101 Switching Protocols
|
||
|
|
│ │ │ ├── 102 Processing (WebDAV)
|
||
|
|
│ │ │ └── 103 Early Hints
|
||
|
|
│ │ ├── 2xx Success
|
||
|
|
│ │ │ ├── 200 OK
|
||
|
|
│ │ │ ├── 201 Created
|
||
|
|
│ │ │ ├── 202 Accepted
|
||
|
|
│ │ │ ├── 203 Non-Authoritative Information
|
||
|
|
│ │ │ ├── 204 No Content
|
||
|
|
│ │ │ ├── 205 Reset Content
|
||
|
|
│ │ │ └── 206 Partial Content
|
||
|
|
│ │ ├── 3xx Redirection
|
||
|
|
│ │ │ ├── 300 Multiple Choices
|
||
|
|
│ │ │ ├── 301 Moved Permanently
|
||
|
|
│ │ │ ├── 302 Found
|
||
|
|
│ │ │ ├── 303 See Other
|
||
|
|
│ │ │ ├── 304 Not Modified
|
||
|
|
│ │ │ ├── 307 Temporary Redirect
|
||
|
|
│ │ │ └── 308 Permanent Redirect
|
||
|
|
│ │ ├── 4xx Client Errors
|
||
|
|
│ │ │ ├── 400 Bad Request
|
||
|
|
│ │ │ ├── 401 Unauthorized
|
||
|
|
│ │ │ ├── 402 Payment Required (reserved)
|
||
|
|
│ │ │ ├── 403 Forbidden
|
||
|
|
│ │ │ ├── 404 Not Found
|
||
|
|
│ │ │ ├── 405 Method Not Allowed
|
||
|
|
│ │ │ ├── 406 Not Acceptable
|
||
|
|
│ │ │ ├── 407 Proxy Authentication Required
|
||
|
|
│ │ │ ├── 408 Request Timeout
|
||
|
|
│ │ │ ├── 409 Conflict
|
||
|
|
│ │ │ ├── 410 Gone
|
||
|
|
│ │ │ ├── 411 Length Required
|
||
|
|
│ │ │ ├── 412 Precondition Failed
|
||
|
|
│ │ │ ├── 413 Payload Too Large
|
||
|
|
│ │ │ ├── 414 URI Too Long
|
||
|
|
│ │ │ ├── 415 Unsupported Media Type
|
||
|
|
│ │ │ ├── 416 Range Not Satisfiable
|
||
|
|
│ │ │ ├── 417 Expectation Failed
|
||
|
|
│ │ │ └── 418 I'm a Teapot (Easter Egg)
|
||
|
|
│ │ └── 5xx Server Errors
|
||
|
|
│ │ ├── 500 Internal Server Error
|
||
|
|
│ │ ├── 501 Not Implemented
|
||
|
|
│ │ ├── 502 Bad Gateway
|
||
|
|
│ │ ├── 503 Service Unavailable
|
||
|
|
│ │ ├── 504 Gateway Timeout
|
||
|
|
│ │ └── 505 HTTP Version Not Supported
|
||
|
|
│ └── Reason Phrase (human-readable text, optional)
|
||
|
|
│
|
||
|
|
├── Headers
|
||
|
|
│ ├── General Headers (same as request)
|
||
|
|
│ │ ├── Cache-Control, Connection, Date, etc.
|
||
|
|
│ │
|
||
|
|
│ ├── Response Headers
|
||
|
|
│ │ ├── Server
|
||
|
|
│ │ ├── Location (used for redirects, 201/3xx)
|
||
|
|
│ │ ├── Vary
|
||
|
|
│ │ ├── Retry-After
|
||
|
|
│ │ └── Set-Cookie
|
||
|
|
│ │
|
||
|
|
│ ├── Representation Headers (describe body)
|
||
|
|
│ │ ├── Content-Type
|
||
|
|
│ │ ├── Content-Encoding
|
||
|
|
│ │ ├── Content-Language
|
||
|
|
│ │ ├── Content-Length
|
||
|
|
│ │ ├── Last-Modified
|
||
|
|
│ │ ├── ETag
|
||
|
|
│ │ └── Allow (which methods are allowed for resource)
|
||
|
|
│ │
|
||
|
|
│ ├── Caching Headers
|
||
|
|
│ │ ├── Age
|
||
|
|
│ │ ├── Expires
|
||
|
|
│ │ ├── Cache-Control
|
||
|
|
│ │ └── Vary
|
||
|
|
│ │
|
||
|
|
│ ├── Security Headers
|
||
|
|
│ │ ├── Strict-Transport-Security (HSTS)
|
||
|
|
│ │ ├── X-Frame-Options
|
||
|
|
│ │ ├── X-Content-Type-Options
|
||
|
|
│ │ ├── Referrer-Policy
|
||
|
|
│ │ ├── Permissions-Policy
|
||
|
|
│ │ └── Content-Security-Policy (CSP)
|
||
|
|
│ │
|
||
|
|
│ └── Custom Headers (X-* or vendor specific)
|
||
|
|
│
|
||
|
|
└── Body (optional)
|
||
|
|
├── HTML (for websites)
|
||
|
|
├── JSON (for APIs)
|
||
|
|
├── XML (older APIs, RSS, SOAP)
|
||
|
|
├── Files (PDF, images, etc.)
|
||
|
|
└── Empty (e.g., 204 No Content)
|