HTTP request and response analyzer
Every web request is a few lines of text: a start line, header fields and a body. Paste a request and its response, from your browser's developer tools, a proxy log or curl -v, and each line is explained with the RFC that defines it, along with how long it can be cached and what is wrong with it.
- RequestGET: Retrieve the current representation of the target resource. Safe (read-only), idempotent (repeating it has the same effect, so it can be retried), cacheable. RFC 9110 §9.3.1
- Response200 OK (success). The request succeeded. RFC 9110 §15.3.1
- ResponseCaches keep a separate copy for each value of Accept-Encoding.
- Browser cache
- fresh for 365 days
- Shared cache (CDN, proxy)
- fresh for 365 days
max-age gives a freshness lifetime of 31,536,000 s; it is already 3,600 s old (Age), so it can be reused without asking the server for 31,532,400 s.
GET /assets/app.3f9a2c.js HTTP/1.1 Host: www.example.com If-None-Match: "3f9a2c"
After 31,532,400 s the copy is stale; the next request then carries the validators. If nothing changed the server answers 304 Not Modified with no body, and the cached copy is reused for another 31,536,000 s.
How to use the analyzer
Paste a request, a response, or both one after the other. The analyzer accepts raw HTTP/1.1 as it appears on the wire or in a proxy log, and the output of curl -v, where sent lines start with > and received lines with <. Browser developer tools can show a request's raw headers in the network panel. Each header is explained with a link to the section of the RFC that defines it, 53 fields in all; the panel on the right lists problems, how long caches may keep the response, the conditional request a cache would send next, and checks on each cookie.
Everything runs in the page. Even so, remove passwords, tokens and session cookies before pasting real traffic; the address bar keeps what you paste so the link can be shared.
Anatomy of an HTTP message
An HTTP request starts with a request line naming the method, the target (usually a path and query) and the protocol version, such as GET /news?page=2 HTTP/1.1. A response starts with a status line: the version, a three-digit status code and a reason phrase, such as HTTP/1.1 404 Not Found. Both continue with header fields, one Name: value per line, with names case-insensitive; an empty line ends the headers and the body, if any, follows.
Since 2022 the definitions are split: RFC 9110 gives the meaning of methods, status codes and fields for every version of HTTP, RFC 9112 the text format of HTTP/1.1, and RFC 9113 and RFC 9114 the binary framing of HTTP/2 and HTTP/3. The fields are the same in all of them (HTTP/2 and HTTP/3 move the request line into pseudo-headers such as :method and :path), so what this page says about headers applies to every version.
Methods: safe and idempotent
| Method | Safe | Idempotent | Typical use |
|---|---|---|---|
| GET | yes | yes | Read a resource |
| HEAD | yes | yes | Read only the headers |
| OPTIONS | yes | yes | Ask what is allowed; CORS preflight |
| PUT | no | yes | Create or replace at a known URL |
| DELETE | no | yes | Remove |
| POST | no | no | Submit, create in a collection, run an action |
| PATCH | no | no | Apply partial changes (RFC 5789) |
A safe method does not ask the server to change anything, so crawlers and prefetchers may send it freely. An idempotent method has the same intended effect whether it arrives once or several times, so a client or proxy can resend it after a connection drops without knowing whether the first one got through. That is why retrying a POST, such as a payment, needs extra care, often an idempotency key the server uses to recognise the repeat.
Status codes
The first digit gives the class: 1xx informational, 2xx success, 3xx redirection, 4xx a problem with the request, 5xx a problem at the server. A few pairs are easy to confuse:
- 301 and 308 are permanent redirects; 302 and 307 temporary. With 301 and 302, browsers turn a POST into a GET when following; 307 and 308 require the same method and body.
- 303 See Other sends the client to another resource with GET, the usual answer to a form POST so that reloading the result does not resubmit it.
- 401 Unauthorized means "who are you?" and must carry WWW-Authenticate; 403 Forbidden means "I know, and no".
- 502 Bad Gateway and 504 Gateway Timeout come from a proxy or load balancer about the server behind it; 503 is the server saying it is overloaded or down for maintenance.
Caching headers and 304
A cache may reuse a stored response without asking the server while it is fresh. RFC 9111 takes the freshness lifetime from s-maxage (shared caches only), then max-age, then Expires minus Date, and subtracts the response's age, which includes the Age header added by caches upstream. In the Static file example, max-age=31536000 gives 31,536,000 s and the response is already 3,600 s old, leaving 31,532,400 s. With none of these headers, a cache may use a heuristic for responses with Last-Modified; RFC 9111 mentions 10% of the time since the last change as typical, which gives the Only Last-Modified example 86,400 s.
When a stored response goes stale, the cache does not have to download it again. It sends a conditional request carrying the response's validators: If-None-Match with the ETag, or If-Modified-Since with Last-Modified. If nothing changed the server answers 304 Not Modified with headers only, and the cache keeps using its copy. no-cache forces this check on every use; no-store forbids keeping a copy at all; private keeps it out of shared caches such as CDNs.
Cookies
A server sets a cookie with a Set-Cookie header, one per cookie, and the browser sends the stored cookies back in a single Cookie header. The attributes decide where and how long: Max-Age or Expires for lifetime (without them, the cookie lasts for the session), Domain and Path for scope, Secure for HTTPS only, HttpOnly to hide it from page scripts, and SameSite to control whether other sites' requests carry it. A session cookie should have all of Secure, HttpOnly and SameSite; in the Login and cookies example, __Host-session gets 0 warnings and theme gets 2 warnings. The __Host- name prefix makes the browser insist on Secure, Path=/ and no Domain, so a subdomain cannot overwrite the cookie.
Where a message ends
Over HTTP/1.1 several messages share one connection, so each must say where its body ends: either Content-Length with the exact number of bytes, or Transfer-Encoding: chunked, which sends the body in pieces, each preceded by its size, and ends with a zero-size piece. A wrong Content-Length makes the receiver wait for bytes that never come, or read the start of the next message as part of this one. A message with both is suspicious: RFC 9112 says Transfer-Encoding wins and lets servers reject it, because a front-end proxy and a back-end server that disagree about the boundary can be made to see a hidden second request. The Common mistakes example has 7 problems, including that one.
HTTP message questions and answers
What does an HTTP request look like?
A start line with the method, the target and the version (GET /index.html HTTP/1.1), then header fields as Name: value lines, then an empty line, then an optional body. A response has the same shape with a status line (HTTP/1.1 200 OK) instead. HTTP/2 and HTTP/3 send the same fields in a binary encoding.
What is the difference between safe and idempotent methods?
A safe method is read-only from the client's point of view: GET, HEAD, OPTIONS and TRACE. An idempotent method has the same effect whether it is sent once or several times: the safe methods plus PUT and DELETE. Clients and proxies may retry idempotent requests after a connection failure; POST and PATCH are neither, so retrying them can repeat the action.
How long can a browser cache a response?
For as long as its freshness lifetime: max-age in Cache-Control, or Expires minus Date, minus the Age the response already has. Without either, a cache may guess from Last-Modified; RFC 9111 suggests 10% of the time since the last change, so a page last modified 10 days before gets 1 day of freshness.
What is the difference between 401 and 403?
401 Unauthorized means the request has no valid credentials and the client should authenticate; it must come with a WWW-Authenticate header saying how. 403 Forbidden means the server understood who is asking and refuses anyway; authenticating again will not help.
What does a 304 Not Modified response mean?
The client asked conditionally, with If-None-Match (an ETag) or If-Modified-Since, and the resource has not changed. The server sends headers only, and the client keeps using its cached copy with the refreshed headers. It saves sending the body again.
Why are Content-Length and Transfer-Encoding together dangerous?
They are two ways of saying where a message ends. If both appear, HTTP/1.1 says Transfer-Encoding wins, and a server may reject the message. When a proxy and the server behind it disagree about which to use, an attacker can hide a second request inside the first: request smuggling.
Further reading
- RFC 9110HTTP SemanticsMethods, status codes and header fields, for every HTTP version.
- RFC 9111HTTP CachingFreshness, age, validation and the Cache-Control directives.
- RFC 9112HTTP/1.1The text format, message framing and chunked transfer coding.
- RFC 6265HTTP State Management MechanismSet-Cookie, Cookie and the cookie attributes.
- MDN Web DocsSet-CookieHow browsers treat SameSite, cookie prefixes and the other attributes today.