aboutsummaryrefslogtreecommitdiff
path: root/lib/std/array_list.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-02-20 03:30:51 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-02-23 02:37:11 -0700
commit6395ba852a88f0e0b2a2f0659f1daf9d08e90157 (patch)
tree9cc1a8b6dce2ccb049667a008c596ab8bcf86e14 /lib/std/array_list.zig
parent9129fb28dcc3c94a709cefd8040f41b9125693ee (diff)
downloadzig-6395ba852a88f0e0b2a2f0659f1daf9d08e90157.tar.gz
zig-6395ba852a88f0e0b2a2f0659f1daf9d08e90157.zip
std.http.Server: rework the API entirely
Mainly, this removes the poorly named `wait`, `send`, `finish` functions, which all operated on the same "Response" object, which was actually being used as the request. Now, it looks like this: 1. std.net.Server.accept() gives you a std.net.Server.Connection 2. std.http.Server.init() with the connection 3. Server.receiveHead() gives you a Request 4. Request.reader() gives you a body reader 5. Request.respond() is a one-shot, or Request.respondStreaming() creates a Response 6. Response.writer() gives you a body writer 7. Response.end() finishes the response; Response.endChunked() allows passing response trailers. In other words, the type system now guides the API user down the correct path. receiveHead allows extra bytes to be read into the read buffer, and then will reuse those bytes for the body or the next request upon connection reuse. respond(), the one-shot function, will send the entire response in one syscall. Streaming response bodies no longer wastefully wraps every call to write with a chunk header and trailer; instead it only sends the HTTP chunk wrapper when flushing. This means the user can still control when it happens but it also does not add unnecessary chunks. Empirically, in my example project that uses this API, the usage code is significantly less noisy, it has less error handling while handling errors more correctly, it's more obvious what is happening, and it is syscall-optimal. Additionally: * Uncouple std.http.HeadParser from protocol.zig * Delete std.Server.Connection; use std.net.Server.Connection instead. - The API user supplies the read buffer when initializing the http.Server, and it is used for the HTTP head as well as a buffer for reading the body into. * Replace and document the State enum. No longer is there both "start" and "first".
Diffstat (limited to 'lib/std/array_list.zig')
0 files changed, 0 insertions, 0 deletions