All three HTTP versions share the same semantics (methods, codes, headers, body); only the transport changes. HTTP/1.1 serves requests on a connection in turn (head-of-line blocking). HTTP/2 multiplexes streams in one TCP connection, but one lost packet delays all of them. HTTP/3 runs on QUIC over UDP, so a loss affects only its stream. API tests do not depend on the version; performance and fallback to HTTP/2 are checked.
Networking · HTTP
DevTools shows h2 in the Protocol column and a colleague sees h3. Does that change API test cases?
You open Network and see h2, while a colleague on the same stand sees h3. The test cases are the same, the response codes are the same, but on slow Wi-Fi the page opens differently for them. The HTTP version does not change what is asked and answered, but it changes how it is delivered. The lesson explains the difference between HTTP/1.1, HTTP/2 and HTTP/3, which problems each next version solved and what matters from this for a tester.
How it works and why. All three versions share the same semantics: methods, codes, headers, body (RFC 9110). What changes is only the way of carrying these semantics over the network. Each version fixes the main pain of the previous one.
Three versions of one protocol
Figure 1. The semantics are the same, the transport changes: what is shared between requests and what happens on packet loss.
HTTP/1.1 is a text protocol over TCP. Keep-alive is on by default: one connection serves many requests, so the handshake is not repeated. But requests on a connection go in turn: a slow response blocks the next ones. This is head-of-line blocking (HOL). Pipelining never took off in practice. The workaround: a browser opens up to ~6 parallel connections per host, and developers "sharded" domains and bundled files.
HTTP/2 (RFC 9113) keeps the semantics but changes the format. Data goes in binary frames, and many streams (requests) are multiplexed in one connection: responses interleave, and neither sharding nor bundling is needed any more. Headers are compressed by HPACK with a shared table, so long Cookie and User-Agent values are not sent in full every time. Server push is effectively retired (Chrome disabled it by default in version 106). In browsers it works only over TLS, with the protocol negotiated via ALPN (h2).
The HTTP/2 problem remained at the TCP level: it is one ordered byte stream. If one packet is lost, TCP holds back everything after it, that is, all streams.
Packet loss on a bad network
HTTP/2 on packet loss
All streams share one TCP connection, so one lost packet delays all of them until it is retransmitted.
HTTP/3 on packet loss
QUIC tracks loss per stream: only the stream that owned the packet waits. The rest keep flowing.
Figure 2. On a lossy network HTTP/2 in one connection can be worse than several HTTP/1.1 connections; HTTP/3 removes that dependency.
HTTP/3 (RFC 9114) runs over QUIC (RFC 9000), and QUIC over UDP, usually on port 443. Reliability, multiplexing and TLS 1.3 are implemented in QUIC itself, hence: a lost packet affects only its own stream; an encrypted connection is established in 1 RTT (0-RTT on resumption is possible); there is connection migration between networks (Wi-Fi → mobile) without a break, because a connection is not identified by the IP address; headers are compressed by QPACK. A browser learns about HTTP/3 from the Alt-Svc header or the HTTPS DNS record, and the first request often still goes over HTTP/2. If UDP is blocked, a silent fallback to HTTP/2 happens.
Example: what was actually negotiated and does the fallback work. First find out what the client uses instead of assuming:
# which version was negotiated (illustrative output)
curl -sS -o /dev/null -w "%{http_version}\n" https://example.com
# 2
curl -sI https://example.com | grep -i alt-svc
# alt-svc: h3=":443"; ma=86400 # the server offers HTTP/3# only for curl builds with HTTP/3 support
curl --http3 -sS -o /dev/null -w "%{http_version}\n" https://example.com
A test for the fallback: Chromium with the --disable-quic flag turns QUIC off, so the browser goes straight to HTTP/2, and the page must still work. The page itself reports the protocol version through nextHopProtocol in Navigation Timing (h2, h3, http/1.1), so it can be asserted:
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{
// QUIC off: the browser goes straight to HTTP/2
name: 'chromium-no-quic',
use: {
...devices['Desktop Chrome'],
launchOptions: { args: ['--disable-quic'] },
},
},
],
// in the test
test.skip(testInfo.project.name !== 'chromium-no-quic');
const proto = await page.evaluate(
() =>
(performance.getEntriesByType('navigation')[0] asPerformanceNavigationTiming).nextHopProtocol,
);
expect(proto).toBe('h2');
Here the assertion expects h2 because QUIC is off, so the test runs only in the chromium-no-quic project (test.skip by testInfo.project.name). In the normal project the first navigation is h2 too, because the browser learns about HTTP/3 from Alt-Svc, so this assertion does not prove the fallback. A real fallback, where the browser tries QUIC and gets no answer, is checked by blocking UDP 443 with a firewall rule on the runner. Note a nuance: corporate networks often block UDP on 443, so a real share of users will be on HTTP/2 even if the server supports HTTP/3. Both paths need testing.
For a tester. The semantics are the same, so API test cases (methods, codes, schemas) do not depend on the version. Three things do. Performance and behaviour on loss and on network switching (mobile users). Header names: in HTTP/2 and HTTP/3 they are always lower case, while HTTP/1.1 does not distinguish case, so a check that "Content-Type is capitalised exactly" breaks, though client libraries usually normalise this. And connection-specific headers (Connection, Keep-Alive, Transfer-Encoding) are forbidden in HTTP/2: a proxy that "passes" them on breaks requests.
Limits and alternatives. HTTP/3 is not necessarily faster: on a stable low-latency network the gain is small, and encryption and user-space processing may cost more. UDP is more often restricted and traffic-shaped. Some tools (debugging proxies, load clients) do not speak HTTP/3 and talk to the server over HTTP/2 or HTTP/1.1, so a measurement may not match what a browser sees. WebSocket starts with an HTTP/1.1 Upgrade; variants for HTTP/2 and HTTP/3 exist (RFC 8441 and RFC 9220) but not every stack supports them.
Common mistakes.
Believing a new version changes the API contract: the transport changes, not methods or statuses.
Comparing speed with a tool that cannot do HTTP/3 and drawing conclusions about what a user sees.
Writing assertions on the exact form of a header (Content-Type capitalised): in h2 they are lower case.
Not testing the fallback: if UDP is blocked and a server or proxy is misconfigured, users fail exactly where the team sees "all works".
Believing server push speeds up a page: it was removed from browsers, and preload replaces it.
Check yourself
Why could HTTP/2 be slower than HTTP/1.1 on a network with packet loss, and what does HTTP/3 change?
Answer
HTTP/2 multiplexes everything in one TCP connection, and TCP delivers data in order, so one lost packet holds back all streams. HTTP/1.1 opens several connections, and a loss affects only one. HTTP/3 runs on QUIC, where loss is handled per stream, so only the affected one waits.
The server supports HTTP/3 and DevTools on the stand always shows h2. Name two reasons.
Answer
The client does not know about HTTP/3 at first: it learns from Alt-Svc or the HTTPS DNS record and uses it from the next connection. Or UDP on 443 is blocked on the path (corporate network, firewall) and the browser fell back to HTTP/2. Check with curl -I for Alt-Svc and with a test from another network.
Related lessons: “What happens when you type a URL in the browser”, “Proxies, load balancers, CDNs and timeouts”, “WebSocket: handshake, frames, ping/pong and closing”.
In an interview.Junior: HTTP/1.1 sends requests in turn, HTTP/2 carries many requests in one connection and compresses headers, HTTP/3 runs over QUIC on UDP. Middle/Senior: The semantics are the same, so API tests do not depend on the version. The difference is in transport: HTTP/2 still suffers HOL blocking at the TCP level, HTTP/3 removes it, and also connects faster and survives a network change. For tests I check the negotiated protocol (nextHopProtocol), the fallback when UDP is blocked, and I do not rely on tools without h3 support.
Proxies, load balancers, CDNs and timeouts
Between the client and the application sit proxies, load balancers and CDNs, and every node has its own timeout, so the shortest one fires. A reverse proxy terminates TLS and routes, a load balancer spreads requests, a CDN caches responses. Codes 502, 503 and 504 are often returned by the proxy, and 504 means it did not wait for the upstream. A round duration such as 60 seconds points to a timeout.
Networking · HTTP
A request keeps failing with 504 at exactly 60 seconds. Is it an application or an infrastructure bug?
A report export works on a small dataset and fails on a large one. The error is always 504, the time is always 60.0 seconds. Random slowness does not look like that: a round number is almost always a coincidence with somebody's timeout. A direct connection between the browser and the application is rare, and every node on the way has its own rules and timeouts. The lesson explains what these nodes do, why each has its own timeout and how to guess from the symptom who caused it.
How it works and why. Each node between the client and the application exists because it solves its own task. Proxies and balancers protect the application, spread the load and terminate TLS, a CDN brings content closer to the user. The price is more places where a request can be delayed or cut.
The path of a request and a timeout at every node
Figure 1. The shortest timeout wins: it cuts the request first, and its code shows which node did it.
A forward proxy stands on the client side (a corporate exit to the internet, Charles, mitmproxy). A reverse proxy stands on the server side (nginx, Envoy): it terminates TLS, serves static files, routes to services, compresses responses.
A load balancer: L4 works with TCP connections (fast, does not see HTTP), L7 understands HTTP and routes by host, path or headers. Algorithms: round-robin, least connections. A health check removes failing instances, "sticky" sessions pin a client to an instance.
A CDN caches responses at the edge, closer to the user, and offloads the origin. Cache errors (a stale file, somebody else's personalised response) are cured with Cache-Control, Vary, versions in the file name and invalidation.
Proxy headers: X-Forwarded-For (the client IP), X-Forwarded-Proto, the standardised Forwarded. If the application does not trust the proxy, it sees the balancer IP, and the rate limit fires for everyone at once.
Timeouts. There is one at every step, and the smallest fires:
connect timeout: how long to wait for TCP to be established;
read/response timeout: how long to wait for data from the server;
idle timeout on a balancer (often 60 s): a connection with no traffic is closed. It also "kills" long requests without an answer and WebSockets without ping;
the client timeout (fetch has none of its own, you need AbortSignal.timeout(ms)), the test timeout and the CI step timeout.
How to get rid of the timeout of a long operation
Wrong
A long operation in one request
The client waits a minute or more. Any node with a shorter timeout cuts the request, and the work on the server may go on without an answer.
Right
202 Accepted and status polling
The request returns a job id at once, the client polls for status. No timeout becomes a limit on how long the work takes.
Figure 2. Raising the timeout on every node is expensive and fragile: after the next data growth the problem returns.
The code shows who answered:
Code
Who returned it and why
502
the proxy got an invalid response or could not connect to the upstream: the app crashed or is restarting
503
no healthy backends or an overloaded service; the application itself may also return it
504
the proxy did not get an upstream response within its timeout
Example: breaking down "exactly 60 seconds". First look at who returned the error and after how many seconds:
curl -sS -o /dev/null -D - -w "%{http_code} %{time_total}\n" \
https://api.example.com/reports/42
# HTTP/2 504# server: nginx # the proxy answered, not the app# 504 60.012 # exactly 60 s: matches a timeout
The server: nginx header and an HTML page instead of JSON say that the proxy answered, not the application. The number 60 matches the default nginx proxy_read_timeout and the default idle timeout of many cloud balancers. Check the proxy configuration:
Conclusion: the application does not finish in 60 seconds, and the proxy cuts the wait. The right fix is an asynchronous model with 202 (see figure 2). The timeout may be raised temporarily and deliberately, but then every node with a shorter value changes, not one. Note also that a test with a 30 second timeout will fail earlier than the 504, with a different message, and without that difference the diagnosis comes out wrong.
Limits and alternatives. Not every "slow" is a timeout. If the time is different every time, it is overload or a dependency; if it is the same, it is a timeout. For WebSocket and SSE, ping or a heartbeat solves the idle timeout. X-Forwarded-For can be forged by the client itself, so the application must trust only headers from known proxies: check it with a test that sends its own X-Forwarded-For and sees whether the IP used for limits and logs changes. A CDN cannot tell that a response is personalised unless the application marks it with Cache-Control: private (or no-store) or Vary, so the "somebody else's personalised response" bug is often in the cache, not the application.
Common mistakes.
Curing a 504 with a retry in a test: it masks the timeout instead of removing it.
Raising the timeout on one node only: the next one, with a shorter value, fires.
Treating 502 and 504 as an application error: they are returned by a proxy or a balancer, and the problem may be behind it.
Not setting a timeout in the test client: fetch will wait until someone else cuts it.
Not accounting for the application seeing the balancer IP until trust in the proxy is configured.
Check yourself
A request returns 504 at exactly 60 seconds every time. Which two hypotheses do you check first?
Answer
A round number points at a timeout: I check proxy_read_timeout or its equivalent in the proxy and the balancer idle timeout, which are often 60 seconds by default. The second hypothesis: the application really does not finish in 60 s, so I look at processing time in its logs. The response body (nginx HTML instead of JSON) and the server header confirm that the proxy answered.
A test with a 30 second timeout fails, while curl with a 120 second timeout gets a 504 at 60. Why do the results differ and what is the right conclusion?
Answer
The test gave up first through its own timeout and did not wait for the 504, so its message differs. Curl reached the proxy timeout. The conclusion about the cause comes from curl: the test and the proxy have timeouts that must be compared, and the real problem is that the operation takes longer than 60 seconds.
Related lessons: “HTTP/1.1, HTTP/2 and HTTP/3: what changed”, “What happens when you type a URL in the browser”, “Diagnosing network failures: curl, dig and error classes”, “WebSocket: handshake, frames, ping/pong and closing”.
In an interview.Junior: Between a client and a server there are proxies, balancers and CDNs. A reverse proxy stands in front of the server, a balancer spreads requests, a CDN caches. 502, 503 and 504 come from them. Middle/Senior: Every node has its own timeout, and the shortest wins. I read "exactly 60 seconds" as a match with an idle or proxy timeout, not random slowness. I move long operations to 202 with status polling, set timeouts explicitly in tests, and check that X-Forwarded-* headers are trusted only from known proxies.