ArticleIntermediate4 min read

From HTTP Request to Application Code

An HTTP request is a self-contained, versioned message that travels over a transport connection (TCP or QUIC). By the time your application handler runs, the framework or server has already completed the connection setup, TLS handshake (for HTTPS), message framing, and parsing. Your code receives a structured representation, not raw bytes.

Author
Pradeep Gajendra
Published
Updated
Technically verified

Scope of this article

Versions
HTTP/1.1 (RFC 9112), HTTP/2 (RFC 9113), HTTP/3 (RFC 9114 overview), TLS 1.3 (RFC 8446)
Environment
General web application servers and frameworks (Node.js, JVM, .NET, etc.) receiving HTTP requests over TCP or QUIC. Applies to both direct connections and those behind reverse proxies/load balancers. No specific language or framework assumed.

This article traces the path from the client’s first packet to the moment your handler is invoked. It focuses on the mechanisms that are already finished before your code sees the request, the failure modes that occur in those layers, and the information that is (and is not) available to you.

1. The Three Phases of an HTTP Session#

HTTP is a request/response protocol. A client establishes a connection, sends a request, and receives a response. As of HTTP/1.1, the connection is persistent by default: after the response is fully received, the same connection may be reused for additional requests unless either side signals closure with Connection: close.

The authoritative description of HTTP semantics (shared by all versions) is RFC 9110. It defines the architecture, terminology, methods, status codes, and header fields. The wire format differs by version:

  • HTTP/1.1 (RFC 9112): text-based framing over TCP.

  • HTTP/2 (RFC 9113): binary frames, streams, and multiplexing over a single TCP connection (almost always inside TLS).

  • HTTP/3 (RFC 9114): binary frames over QUIC (UDP).

Your application framework almost always hides these differences. The semantics your code observes (methods, status codes, headers) remain the same.

2. Connection Establishment and TLS#

Before any HTTP bytes are exchanged, a transport connection must exist.

TCP handshake (HTTP/1.1 and HTTP/2):
Three-way handshake (SYN, SYN-ACK, ACK). This alone costs one round-trip.

TLS handshake (HTTPS):
Modern deployments use TLS 1.3 (RFC 8446). A typical full handshake completes in one round-trip after the TCP connection is up:

  1. ClientHello — supported versions, cipher suites, key shares, SNI, ALPN.

  2. ServerHello + EncryptedExtensions + Certificate + CertificateVerify + Finished.

  3. Client Finished.

Session resumption and 0-RTT can reduce this further, but the first connection to a host still pays the full cost. HTTP/2 and HTTP/3 are almost always negotiated inside this handshake via ALPN.

Practical consequence: The first request to a cold host pays TCP + TLS latency before your server even sees the HTTP request line. Subsequent requests on a persistent connection avoid this.

3. Anatomy of an HTTP Request and Response#

Per RFC 9110, both requests and responses share a common structure:

  • Control data (method/target/version or status code)

  • Header fields

  • Optional content (body)

  • Optional trailer fields

A minimal HTTP/1.1 request:

Terminal
GET /users/42 HTTP/1.1Host: api.example.comAccept: application/jsonUser-Agent: StackTalk-Example/1.0

A corresponding response:

Terminal
HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 45Date: Sun, 22 Nov 2026 14:30:00 GMT{"id":42,"email":"user@example.com"}

Important distinctions:

  • Safe methods (GET, HEAD, OPTIONS): should not change server state.

  • Idempotent methods (GET, PUT, DELETE): multiple identical requests should have the same effect as one.

  • POST is neither safe nor idempotent by default. This matters later when you add retries.

Frameworks parse these into language-native objects. Common fields you receive:

Field

Source

Notes

Method

Request line

Upper-cased by most frameworks

Path / Query

Request target

Already decoded

Headers

Header fields

Often lower-cased; multi-value supported

Body

Content

Parsed (JSON, form) or raw stream

Remote address

Transport

May be a proxy; use trusted headers carefully

Protocol version

Start line / framing

Usually hidden

4. What the Framework Does Before Your Handler Runs#

Typical server or framework pipeline (Express, Fastify, Spring Boot, ASP.NET, etc.):

  1. Accept TCP/QUIC connection.

  2. Complete TLS handshake.

  3. Read and frame the HTTP message (handle chunked encoding, Content-Length, HTTP/2 streams).

  4. Parse start line and headers.

  5. Optionally parse body according to Content-Type (or leave it as a stream).

  6. Run middleware (logging, auth, body limits, CORS).

  7. Route to your handler and invoke it with the structured request object.

  8. Serialize your response and write it back on the same connection.

Your handler therefore never sees:

  • Raw TCP segments or TLS records.

  • Incomplete messages.

  • The exact framing used by HTTP/2 or HTTP/3 (unless you explicitly access the raw stream).

5. Persistent Connections and Multiplexing#

HTTP/1.1: One request at a time per connection (pipelining exists but is rarely used by browsers because responses must be returned in order). Servers and clients keep the connection open for reuse. Idle timeouts eventually close it.

HTTP/2: Multiple streams on one connection. A slow response on one stream does not block others at the HTTP layer (though TCP head-of-line blocking still exists). Flow control and prioritization are part of the protocol (RFC 9113).

HTTP/3: Streams are independent even at the transport layer because QUIC avoids TCP head-of-line blocking.

Operational note: Under load, connection reuse is critical. Opening a new connection per request adds latency and can exhaust file descriptors or connection limits on both sides.

6. Failure Modes in the Layers Before Your Code#

Failure mode

Where it occurs

What you observe

Mitigation

Slow TLS handshake

Connection setup

High time-to-first-byte on cold requests

Connection reuse, TLS session resumption

Oversized headers

Parsing

431 or connection reset

Server header size limits

Incomplete body / early close

Framing

Truncated body or error in middleware

Content-Length / chunked validation

Proxy rewriting Host / X-Forwarded-*

Intermediaries

Wrong host or client IP

Explicit trusted proxy configuration

Request smuggling

Framing ambiguity

Unexpected requests on the connection

Consistent Content-Length / Transfer-Encoding

Idle connection timeout

Transport / server

Subsequent request fails with reset

Keep-alive tuning, connection pooling on client

7. Practical Checklist Before You Write the Handler#

  • Generate or propagate a request ID at the earliest middleware so it can travel with logs and later database work.

  • Enforce body size limits before full parsing.

  • Treat all headers that can be set by clients (X-Forwarded-For, Host, etc.) as untrusted unless you control the proxy.

  • Prefer streaming body parsers for large uploads rather than buffering everything in memory.

  • Log the protocol version and whether the connection was reused when debugging latency.

Full Path from Client to Handler

Diagram

What This Protects Against#

Treating the arrival of a structured request object as the start of the system. Latency, connection limits, header attacks, and framing bugs all occur before your handler. Later articles in the series assume this pipeline is already understood when they discuss connection pools and database work.

Sources#


Core HTTP Specifications
[1]RFC 9110 – HTTP Semantics
[2]RFC 9112 – HTTP/1.1
[3]RFC 9113 – HTTP/2
[4]RFC 9114 – HTTP/3 (referenced for completeness)

TLS
[5]RFC 8446 – The Transport Layer Security (TLS) Protocol Version 1.3

Practical Overviews
[6]MDN – A typical HTTP session
[7]MDN – Connection management in HTTP/1.x
[8]MDN – HTTP messages
[9]Cloudflare – What happens in a TLS handshake?
[10]Palo Alto Networks – What Is the TLS Handshake?

Known limitations

Focuses on the path up to the application handler; does not cover application-level routing, middleware implementation details, or body parsing edge cases beyond high-level notes. TLS handshake description is simplified to the common TLS 1.3 full handshake; session resumption and 0-RTT are mentioned but not fully detailed. HTTP/3 and QUIC are covered at a high level only. Assumes a standard origin server; advanced intermediary behaviors (complex CDN edge logic, service mesh) are out of scope. Schematic diagrams are illustrative, not measured data.

Sources

  1. [1]
    RFC 9110 – HTTP Semantics

    publication date unknown · retrieved 2026-11-22

  2. [2]
    RFC 9112 – HTTP/1.1

    publication date unknown · retrieved 2026-11-22

  3. [3]
    RFC 9113 – HTTP/2

    publication date unknown · retrieved 2026-11-22

  4. [4]
    RFC 9114 – HTTP/3 (referenced for completeness)

    publication date unknown · retrieved 2026-11-22

  5. [5]
    RFC 8446 – The Transport Layer Security (TLS) Protocol Version 1.3

    publication date unknown · retrieved 2026-11-22

  6. [6]
    MDN – A typical HTTP session

    publication date unknown · retrieved 2026-11-22

  7. [7]
    MDN – Connection management in HTTP/1.x

    publication date unknown · retrieved 2026-11-22

  8. [8]
    MDN – HTTP messages

    publication date unknown · retrieved 2026-11-22

  9. [9]
    Cloudflare – What happens in a TLS handshake?

    publication date unknown · retrieved 2026-11-22

  10. [10]
    Palo Alto Networks – What Is the TLS Handshake?

    publication date unknown · retrieved 2026-11-22

Spotted an error? Use “Suggest a correction” in the discussion, or read our corrections policy.

Discussion

Sign in to join the discussion. Reading is always open.

Loading discussion…

Report comment