networking, updated

HTTP

The Hypertext Transfer Protocol carries the web and most APIs: requests with a method, path and headers, answered with a status code, headers and a body. Usually wrapped in TLS as HTTPS.

OSI layer
7 Application
Carried in
TCP (HTTP/1.1, HTTP/2); QUIC over UDP (HTTP/3)
Ports
80/tcp, 443/tcp (HTTPS), 443/udp (HTTP/3), 8080/tcp (proxies, dev)
Specs
RFC 9110, RFC 9112, RFC 9113, RFC 9114
Wireshark filter
http || http2 || http3
Encrypted
no

Packet structure

HTTP/1.1 is text. A request line, headers, an empty line (\r\n\r\n), then the optional body:

POST /api/login HTTP/1.1
Host: app.example.com
User-Agent: Mozilla/5.0 (...)
Content-Type: application/json
Content-Length: 39
Cookie: session=abc123

{"user":"alice","password":"hunter2"}
HTTP/1.1 302 Found
Location: /dashboard
Set-Cookie: session=def456; Secure; HttpOnly; SameSite=Lax
Content-Length: 0

HTTP/2 carries the same meaning in binary frames, many requests multiplexed over one connection as streams:

HTTP/2 frame9 bytes + variable

Select a field to see what it does.

RFC 9113. Every HTTP/2 frame has this 9-byte header. HTTP/1.1 has no binary format; HTTP/3 uses similar frames inside QUIC streams.

How it works

MethodUse
GET, HEADRead (HEAD: headers only)
POSTSubmit data, call an action
PUT, PATCH, DELETEChange resources (APIs)
OPTIONSCORS preflight, allowed methods
CONNECTOpen a tunnel through a proxy (HTTPS via proxy)
TRACEEcho the request; should be disabled
StatusMeaning
1xxInformational (101 Switching Protocols: WebSocket upgrade)
2xxSuccess (200 OK, 201 Created, 204 No Content)
3xxRedirect (301/308 permanent, 302/307 temporary, 304 Not Modified)
4xxClient error (400, 401 needs auth, 403 forbidden, 404, 405, 429 rate limit)
5xxServer error (500, 502 bad gateway, 503 unavailable, 504 gateway timeout)

Message length: Content-Length or Transfer-Encoding: chunked. When a proxy and a back end disagree on which one counts, you get request smuggling.

Versions: HTTP/1.1 sends one request at a time per connection (browsers open about 6). HTTP/2 multiplexes streams over one TLS connection (ALPN h2). HTTP/3 runs over QUIC on UDP 443, announced with the Alt-Svc header or an HTTPS DNS record.

In Wireshark

FilterShows
http.requestHTTP/1.x requests
http.request.method == "POST"POSTs (logins, uploads)
http.response.code >= 400Errors
http.host contains "example"Requests to a host
http.user_agent contains "curl"Requests by user agent (scripts, scanners, malware)
http.authorizationBasic/Bearer credentials in clear text
http.cookieCookies
http2.type == 1HTTP/2 HEADERS frames (needs TLS keys)
http2.type == 3RST_STREAM (Rapid Reset floods)
tcp.port == 80 && !httpNon-HTTP on port 80

File › Export Objects › HTTP extracts downloaded files. HTTPS needs the TLS session keys (see TLS).

What normal looks like: almost everything on 443 encrypted; plain HTTP mostly redirects to HTTPS, OCSP/CRL checks, updates and IoT devices.

Security notes

References

§ home
~/knubertus/home/
1,1 Top