std.http.Server: handle expect: 100-continue requests
The API automatically handles these requests as expected. After receiveHead(), the server has a chance to notice the expectation and do something about it. If it does not, then the Server implementation will handle it by sending the continuation header when the read stream is created. Both respond() and respondStreaming() send the continuation header as part of discarding the request body, only if the read stream has not already been created.
This commit is contained in:
@@ -26,17 +26,7 @@ fn handleRequest(request: *http.Server.Request, listen_port: u16) !void {
|
||||
request.head.target,
|
||||
});
|
||||
|
||||
if (request.head.expect) |expect| {
|
||||
if (mem.eql(u8, expect, "100-continue")) {
|
||||
@panic("test failure, didn't handle expect 100-continue");
|
||||
} else {
|
||||
return request.respond("", .{
|
||||
.status = .expectation_failed,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const body = try request.reader().readAllAlloc(salloc, 8192);
|
||||
const body = try (try request.reader()).readAllAlloc(salloc, 8192);
|
||||
defer salloc.free(body);
|
||||
|
||||
var send_buffer: [100]u8 = undefined;
|
||||
|
||||
Reference in New Issue
Block a user