authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-18 20:26:09-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-23 02:37:11-07:00
logc7fc2d76ce2b9b1cedd6d71232f31ba9556f05d9
treeed9bc760804e8b488e38c053778be9d409b1facc
parent6129ecd4fe88e14531db98866c92c4a5660849ee

std.http.Server: move closing bool

It does not belong in the Connection struct

2 files changed, 5 insertions(+), 6 deletions(-)

lib/std/http/Server.zig+5-4
......@@ -4,6 +4,7 @@ reason: ?[]const u8,
44transfer_encoding: ResponseTransfer,
55keep_alive: bool,
66connection: Connection,
7connection_closing: bool,
78
89/// Externally-owned; must outlive the Server.
910extra_headers: []const http.Header,
......@@ -25,11 +26,11 @@ pub fn init(connection: std.net.Server.Connection, options: Server.Request.InitO
2526 .connection = .{
2627 .stream = connection.stream,
2728 .protocol = .plain,
28 .closing = true,
2929 .read_buf = undefined,
3030 .read_start = 0,
3131 .read_end = 0,
3232 },
33 .connection_closing = true,
3334 .request = Server.Request.init(options),
3435 .version = .@"HTTP/1.1",
3536 .status = .ok,
......@@ -232,7 +233,7 @@ pub fn reset(res: *Server) ResetState {
232233
233234 if (!res.request.parser.done) {
234235 // If the response wasn't fully read, then we need to close the connection.
235 res.connection.closing = true;
236 res.connection_closing = true;
236237 return .closing;
237238 }
238239
......@@ -240,7 +241,7 @@ pub fn reset(res: *Server) ResetState {
240241 // and its value is not "close". The server and client must both agree.
241242 //
242243 // send() defaults to using keep-alive if the client requests it.
243 res.connection.closing = !res.keep_alive or !res.request.keep_alive;
244 res.connection_closing = !res.keep_alive or !res.request.keep_alive;
244245
245246 res.state = .start;
246247 res.version = .@"HTTP/1.1";
......@@ -253,7 +254,7 @@ pub fn reset(res: *Server) ResetState {
253254 .client_header_buffer = res.request.parser.header_bytes_buffer,
254255 });
255256
256 return if (res.connection.closing) .closing else .reset;
257 return if (res.connection_closing) .closing else .reset;
257258}
258259
259260pub const SendError = Connection.WriteError || error{
lib/std/http/Server/Connection.zig-2
......@@ -1,8 +1,6 @@
11stream: std.net.Stream,
22protocol: Protocol,
33
4closing: bool,
5
64read_buf: [buffer_size]u8,
75read_start: u16,
86read_end: u16,