aboutsummaryrefslogtreecommitdiff
path: root/lib/std/http/Server.zig
diff options
context:
space:
mode:
authorRyo Ota <nwtgck@nwtgck.org>2023-04-21 10:17:16 +0900
committerRyo Ota <nwtgck@nwtgck.org>2023-04-21 10:17:16 +0900
commitafebef2465a828132f87cd2aeff0c5873ca10de5 (patch)
tree05fd7b6ea576ed19cc6a6686ae3ae622a7600eb3 /lib/std/http/Server.zig
parent06763c4c8c35d2e984ee2315e674a01d5506ded1 (diff)
downloadzig-afebef2465a828132f87cd2aeff0c5873ca10de5.tar.gz
zig-afebef2465a828132f87cd2aeff0c5873ca10de5.zip
create std.http.Server.Response.deinit to handle keepalive connections
Diffstat (limited to 'lib/std/http/Server.zig')
-rw-r--r--lib/std/http/Server.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/std/http/Server.zig b/lib/std/http/Server.zig
index b1205594ad..59b76ea20d 100644
--- a/lib/std/http/Server.zig
+++ b/lib/std/http/Server.zig
@@ -336,6 +336,10 @@ pub const Response = struct {
headers: http.Headers,
request: Request,
+ pub fn deinit(res: *Response) void {
+ res.server.allocator.destroy(res);
+ }
+
/// Reset this response to its initial state. This must be called before handling a second request on the same connection.
pub fn reset(res: *Response) void {
res.request.headers.deinit();
@@ -359,8 +363,6 @@ pub const Response = struct {
if (res.request.parser.header_bytes_owned) {
res.request.parser.header_bytes.deinit(res.server.allocator);
}
-
- res.server.allocator.destroy(res);
} else {
res.request.parser.reset();
}