Predict HTTP redirects and method handling
Predict a redirect by reading its status, Location value, original method, and client behavior together.
- redirects
- methods
- status codes
A redirect response does not contain the follow-up response
A redirect tells the client where it can make another request. The Location
field supplies a reference that the client resolves against the original target.
The client then decides whether and how to follow it.
HTTP/1.1 301 Moved Permanently
Location: /manual/current
Content-Length: 0
Expected result: a redirect-capable client can resolve the relative reference
and request /manual/current. This response alone does not prove that the target
exists or that every client will follow automatically.
Status selects permanence and method behavior
301 and 308 indicate permanent redirection. 302 and 307 indicate temporary
redirection. For methods other than GET or HEAD, 307 and 308 explicitly
preserve the method and request content when followed automatically.
Historical user-agent behavior permits POST to become GET after 301 or
302. Use 303 See Other when the intended follow-up is explicitly a retrieval,
and use 307 or 308 when the original method and content must be preserved.
Trace chains as separate exchanges
Every hop has its own status, Location, cache behavior, protocol version, and
responding layer. A browser’s final address hides those intermediate decisions.
Capture the chain without following first, then follow with an explicit hop limit.
curl --silent --show-error --head https://example.invalid/old-path
Expected result: one response exposes the first status and Location without
silently collapsing the chain. The reserved host is illustrative; test only a
destination you control or are authorized to inspect.
Redirects can be cached
Some redirects are heuristically cacheable, and explicit cache fields can affect reuse. A changed origin rule might appear unchanged because a browser or shared cache reuses an earlier redirect. Record age and cache fields while locating the hop that produced it.
