FULL_STACK_DEVELOPER_2026_COMPLETE - Phase 05 HTTP Request and Response Anatomy
VOLUME 02 - FRONTEND + BACKEND FOUNDATIONS
HTTP Request and Response Anatomy
Methods, targets, headers, content, JSON and representations
HTTP is the contract between independent programs.
REQUEST
HTTP Client TaskFlow API
PowerShell / browser / later Next.js NestJS + Fastify
RESPONSE
method + target + headers + optional body
status + headers + optional body
Figure - HTTP request/response exchange. Phase 05 studies the protocol before Phase 06 introduces a browser cross-origin call.
Book 2 of Phase 05
FULL_STACK_DEVELOPER_2026_COMPLETE - Phase 05 HTTP Request and Response Anatomy
Anatomy of an HTTP request
POST /todos HTTP/1.1
request line: method + target + protocol
Content-Type: application/json
Accept: application/json
headers: metadata about the request
body: representation sent to the server
Figure - Simplified HTTP request anatomy. HTTP/2 and HTTP/3 encode messages differently on the wire, but the semantic concepts
remain method, target, headers and content.
Method
The method communicates the request semantics. GET asks for a representation; POST commonly submits content for
processing or creation; PUT requests replacement; PATCH requests a partial modification; DELETE requests removal.
Target
The request target identifies the addressed resource. In TaskFlow, /todos identifies the collection while /todos/3 identifies
one member. Query parameters can refine a request later, such as /todos?completed=true.
Headers
Header Why it matters
Content-Type: application/json Describes the media type of request content being sent.
Accept: application/json Expresses a representation preference for the response.
Authorization: Bearer ... Carries credentials later when authentication is introduced.
Cache-Control Influences caching behavior when relevant.
Body / content
A request may carry content. For a Todo creation request, JSON can represent the new data. GET normally retrieves data and
should not depend on a request body for ordinary API design.
JSON is a representation format, not HTTP itself
HTTP can carry many media types. TaskFlow uses JSON because it maps naturally to JavaScript data and is widely
supported. The protocol and the representation format remain separate concepts.
Example JSON representation
FULL_STACK_DEVELOPER_2026_COMPLETE - Phase 05 HTTP Request and Response Anatomy
{
"title": "Learn HTTP",
"completed": false
}
Anatomy of an HTTP response
HTTP/1.1 201 Created
status line: protocol + status code + reason phrase
Content-Type: application/json
Location: /todos/3
response headers: metadata and controls
{"id":3,"title":"Learn HTTP","completed":false}
response body: selected representation
Figure - Simplified HTTP response anatomy. The status code is part of the contract, not decoration around JSON.
The status code summarizes the outcome at the protocol level. Headers provide metadata or controls. The response content
carries a representation when one is appropriate. A well-designed client uses all three instead of parsing a JSON message
string to guess whether the request succeeded.
Representation vs database row
Later, Prisma returns database records, but an API response does not have to expose a database row exactly as stored. A
representation is part of the API contract. This distinction becomes important when hiding internal fields, combining data or
versioning an API.
Boundary rule
Do not let the fact that JavaScript objects serialize easily to JSON trick you into thinking every internal object should
automatically become a public API response. Public representations are contracts.
Official source notes
Primary protocol reference: RFC 9110 - HTTP Semantics (RFC Editor). Supplemental developer reference: MDN HTTP Reference and
HTTP Request Methods. Nest-specific routing and status behavior reference: NestJS Controllers documentation.
This phase teaches HTTP semantics independent of a specific transport version. HTTP/2 and HTTP/3 change framing and transport details,
while request methods, target resources, headers, status codes and representation semantics remain the important application-level concepts
for this course.