The Runtime Theory
easyReference#http

Parse an HTTP Exchange

Given a raw HTTP request and response, identify the method, status code, headers, and body.

The Runtime Theory Team1 min read
Solve it

Solving happens on the judge — come back and mark it done

Sample cases

inGET /index.html HTTP/1.1 Host: example.com

outMethod: GET. Path: /index.html. HTTP version: 1.1. Host header: example.com. No body.

inHTTP/1.1 200 OK Content-Type: text/html Content-Length: 5 Hello

outStatus: 200 OK. Content-Type: text/html. Content-Length: 5. Body: Hello.

inPOST /api/login HTTP/1.1 Host: example.com Content-Type: application/json Content-Length: 27 {"username":"alice","password":"secret"}

outMethod: POST. Path: /api/login. Body is JSON with username and password fields. Content-Type: application/json. ⚠ Warning: passwords should never be sent in plaintext.

Parse an HTTP Exchange

HTTP is a text-based protocol where each message starts with a request/status line, followed by headers (key-value pairs), a blank line, and an optional body.

Request Format

plaintext
METHOD /path HTTP/1.1
Header-Name: value
 
[body]

Response Format

plaintext
HTTP/1.1 STATUS_CODE REASON_PHRASE
Header-Name: value
 
[body]

Key Fields to Identify

  • Method: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
  • Status code: 2xx (success), 3xx (redirect), 4xx (client error), 5xx (server error)
  • Headers: Content-Type, Content-Length, Host, Cache-Control, Set-Cookie
  • Body: The payload (for POST/PUT requests) or response content
plaintext
 

One dispatch a week

The trace behind each problem, the tradeoff that explains it, and one technical dispatch per week — no noise.

One technical dispatch per week. No noise.

Not started

Sign in to save your learning progress.

Sign in to save