To turn a word-ladder REPL into a web application, a server needs more than a stream of bytes: it needs a way to understand what a client wants and reply. HTTP supplies those semantics for accessing or modifying resources. section 4.0 section 4.2.3
HTTP sits above TCP, which maintains a connection between machines and deals with lost IP packets. IP provides the underlying system for sending messages between connected devices. Zig’s std.http is designed to work with a std.net TCP server: replace the communication loop with request parsing and a response. section 4.2.1 section 4.2.3
Table 4.1 Request components
| Component | Examples | Purpose |
URL |
The server can use this to retrieve different pages or execute different behavior, especially based on routing (the 'learn/' bit). |
|
Method |
|
This encodes the wishes of the client. |
Headers |
|
This series of key/value pairs tells the server what to do with a request. |
Body |
N/A |
Depending on the method, this might be empty or contain context-specific data for the server. |
A request combines a URL, method, headers, and an optional body. The method expresses the client’s intent; the other components identify the resource or provide context. section 4.2.3
A response uses a status code to report the outcome, along with headers and potentially a body. Common codes include 200 (OK), 404 (Not Found), and 500 (Internal Server Error). section 4.2.3
Asking for a page or submitting data
A GET request says, in effect, “Please give me this page!” The server might return 200 with HTML or 404 if the page is not found. A POST asks the server to process data; a 200 response can acknowledge success without a body. section 4.2.3










