From abde76a808df816ea12a8a2dbf8e6b53ff9b110f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 21 Feb 2024 23:47:35 -0700 Subject: 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. --- test/standalone/http.zig | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'test') diff --git a/test/standalone/http.zig b/test/standalone/http.zig index 5b44a14032..ff6467fc6c 100644 --- a/test/standalone/http.zig +++ b/test/standalone/http.zig @@ -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; -- cgit v1.2.3