π Stage 3: HTTP/1.1 Fundamentals¶
π― Learning Objectives¶
By the end of this stage, you will be able to:
- Explain the HTTP request/response model and message format.
- Understand and use HTTP methods, headers, and status codes.
- Demonstrate persistent connections, pipelining, and limitations of HTTP/1.1.
- Analyze HTTP traffic in plaintext and through TLS.
- Prepare to compare HTTP/1.1 vs HTTP/2 in the next stage.
π Suggested Duration¶
1 week (6β8 hours total) - 3h theory - 3β5h labs and captures
π Section 1: HTTP Overview¶
π§ Concepts to Learn¶
- HTTP = Hypertext Transfer Protocol, a request-response protocol.
- Operates at the application layer (Layer 7 of TCP/IP model).
- Used by browsers, APIs, and many other services (REST, telemetry, etc.).
π§© Model¶
π§ͺ Lab 1 β Observe a Simple HTTP Exchange¶
-
Run:
-
Observe:
-
The request headers (Host, User-Agent, Accept, etc.).
-
The response headers and status code (e.g., 200 OK).
-
Repeat with:
β Note that now there is a TLS handshake before the HTTP exchange.
π Section 2: HTTP Message Structure¶
π§ Request Format¶
π§ Response Format¶
π§© Components¶
- Start line:
GET /path HTTP/1.1orHTTP/1.1 200 OK - Headers: key-value pairs (Host, Content-Type, etc.)
- Body: optional data (for POST requests or responses)
π§ͺ Lab 2 β View Full Request/Response¶
Run:
Then:
Observe the POST body and how the Content-Length header appears.
π Section 3: HTTP Methods¶
π§ Common Methods¶
| Method | Description |
|---|---|
| GET | Retrieve a resource |
| POST | Submit data to the server |
| PUT | Replace a resource |
| DELETE | Remove a resource |
| HEAD | Retrieve headers only |
| OPTIONS | Query available methods |
π§ͺ Lab 3 β Test Methods with curl¶
Observe status codes and headers.
π Section 4: HTTP Headers and Status Codes¶
π§ Common Headers¶
| Type | Examples |
|---|---|
| General | Date, Connection |
| Request | Host, User-Agent, Accept, Authorization |
| Response | Server, Content-Type, Content-Length, Set-Cookie |
| Entity | Content-Encoding, Cache-Control |
π§ Common Status Codes¶
| Code | Meaning
| --- | --- || 200 | OK | | 301 | Moved Permanently | | 302 | Found (Redirect) | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 404 | Not Found | | 500 | Internal Server Error |
π§ͺ Lab 4 β Header and Code Inspection¶
-
Request only headers:
-
Observe redirections:
β Youβll see a 301 redirect to https://github.com
- Follow redirects automatically:
π Section 5: Persistent Connections and Pipelining¶
π§ Concepts¶
- HTTP/1.0 closed the TCP connection after every request.
- HTTP/1.1 introduced persistent connections (
Connection: keep-alive), allowing multiple requests over one TCP session. - Pipelining (sending multiple requests without waiting for responses) existed but was rarely used due to head-of-line blocking.
π§ͺ Lab 5 β Compare Keep-Alive vs Close¶
-
Use:
-
Observe in Wireshark:
-
With
close, TCP FIN occurs right after the response. - With
keep-alive, TCP stays open for a short period.
π Discussion¶
HTTP/1.1βs performance was limited because: - Only one request per connection at a time (sequential). - Many small objects required many parallel TCP connections.
β These inefficiencies motivated HTTP/2βs multiplexing (coming next).
π Section 6: Compression and Chunked Transfer¶
π§ Concepts¶
Content-Encoding: gzip compresses the body to reduce size.Transfer-Encoding: chunked sends the body in parts when the size is unknown.
π§ͺ Lab 6 β Observe Gzip and Chunked Encoding¶
β Observe headers likeContent-Encoding: gzip and Transfer-Encoding: chunked.
π Section 7: Authentication and Cookies¶
π§ Basic Authentication¶
- Header:
Authorization: Basic <base64> - Server responds with
401 Unauthorizedif credentials missing.
π§ Cookies¶
Set by the server using Set-Cookie header. Sent by client in Cookie header for subsequent requests.
π§ͺ Lab 7 β Test Authentication and Cookies¶
Observe how cookies are stored and sent.
π Section 8: Wireshark Analysis of HTTP¶
π§ͺ Lab 8 β Full Capture¶
- Start Wireshark and filter
tcp.port == 80. - Visit
http://httpbin.org/get. - Observe:
- HTTP request and response in plaintext.
- Headers and body structure.
- Then try
`https://httpbin.org/get. - Youβll see TLS handshake, but no readable HTTP payload (encrypted).
π§ Insight¶
This makes clear why TLS is essential β it hides HTTP details from the network.
π Section 9: Common Troubleshooting Scenarios¶
| Problem | Cause | Example |
|---|---|---|
| 404 Not Found | Wrong path | /wrongpage |
| 403 Forbidden | Access denied | Permissions issue |
| 400 Bad Request | Malformed request | Missing Host header |
| 500 Internal Server Error | Server-side bug | Check server logs |
| Long load times | Too many TCP connections | HTTP/1.1 limitation |
π§ͺ Lab 9 β Debug a 400 Error¶
Try sending an invalid request:
β Observe the server response (likely 400 Bad Request).
π§ Knowledge Check¶
- What are the main components of an HTTP request and response?
- How does HTTP/1.1 differ from HTTP/1.0?
- Why does
Connection: keep-aliveimprove performance? - What are the downsides of HTTP/1.1 that HTTP/2 solves?
- How can you view HTTP traffic if itβs encrypted by TLS?
π Stage 3 Completion Outcome¶
You should now be able to: β Read and interpret HTTP/1.1 requests and responses. β Use curl effectively for debugging HTTP behavior. β Recognize the effect of persistent connections and pipelining. β Capture and analyze HTTP headers and status codes. β Explain HTTP/1.1βs performance limitations and why HTTP/2 exists.