QA Interview Hub · Knowledge base · Quizzes · Українська

Networking › HTTP versions and infrastructure

HTTP/1.1, HTTP/2 and HTTP/3: what changed

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

HTTP/1.1: text over TCPrequests in turn, up to ~6 connections per hostHTTP/2: binary frames over TCPmany streams in one connection, HPACKHTTP/3: QUIC over UDPindependent streams, TLS 1.3 inside, migration
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] as
      PerformanceNavigationTiming).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.

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.

More articles in this chapter