Practice & Assessment
Test your understanding of HTTP Fundamentals
Multiple Choice Questions
6A mobile app retries a failed network request automatically. Which HTTP method is safe to retry without risking duplicate data?
A client receives a 401 response from an API. What should it do next?
Which HTTP version eliminated head-of-line blocking at the TCP level by switching to UDP?
Your server returns '301 Moved Permanently' when a URL changes. Six months later you want to reverse the redirect. What problem will you face?
What is the correct Content-Type header for sending JSON in an HTTP request body?
An API returns '204 No Content' after a successful DELETE request. Your client code throws an error trying to parse the response body. What is wrong?
Coding Challenges
1Raw HTTP Request Builder
Write a function buildHttpRequest(method, url, headers, body) that returns a raw HTTP/1.1 request string with correct CRLF line endings, the Host header automatically derived from the URL, Content-Length set if a body is present, and a blank line separating headers from body. Input: method string, full URL string, headers object, optional body string. Output: complete raw HTTP/1.1 request message as a string. Test with GET (no body) and POST (with JSON body). Estimated time: 20–25 minutes.
Mini Project
HTTP Inspector Proxy
Build a local HTTP proxy server (Node.js or Python) that listens on localhost:8080 and forwards requests to a target server specified as a CLI argument. For every request-response pair the proxy must: (1) log the request method, path, and all request headers; (2) forward the request to the target and receive the response; (3) log the response status code and all response headers; (4) classify the status code into its category (1xx–5xx) with a human-readable label; (5) detect and log whether the method is safe, idempotent, or neither; (6) pass the response body through to the client unchanged. Test it with curl configured to use the proxy (curl -x localhost:8080 http://httpbin.org/get). No external proxy libraries — use raw TCP sockets or the http standard library.
