Code Room
CodingMediumcod-g1027
Subject Protocol http parsingLevel Entry–Mid~20 minCommon in Networking & APIs · Algorithms & data structures interviewsIndustries Software development, Telecom

Question

Parse a raw HTTP request. The request is a string with lines separated by CRLF (\r\n); the request line comes first (METHOD PATH VERSION), followed by zero or more 'Name: Value' header lines, terminated by a blank line. Return [method, path, version, headers] where headers is a dict mapping lowercased header names to their trimmed values. Assume each header name appears at most once.

Implement
parse_request(raw: str) → list
Examples
in["GET /index.html HTTP/1.1\r\nHost: example.com\r\nAccept: text/html\r\n\r\n"]out["GET","/index.html","HTTP/1.1",{"host":"example.com","accept":"text/html"}]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.