| ... | @@ -4,6 +4,7 @@ reason: ?[]const u8, | ... | @@ -4,6 +4,7 @@ reason: ?[]const u8, |
| 4 | transfer_encoding: ResponseTransfer, | 4 | transfer_encoding: ResponseTransfer, |
| 5 | keep_alive: bool, | 5 | keep_alive: bool, |
| 6 | connection: Connection, | 6 | connection: Connection, |
| | 7 | connection_closing: bool, |
| 7 | | 8 | |
| 8 | /// Externally-owned; must outlive the Server. | 9 | /// Externally-owned; must outlive the Server. |
| 9 | extra_headers: []const http.Header, | 10 | extra_headers: []const http.Header, |
| ... | @@ -25,11 +26,11 @@ pub fn init(connection: std.net.Server.Connection, options: Server.Request.InitO | ... | @@ -25,11 +26,11 @@ pub fn init(connection: std.net.Server.Connection, options: Server.Request.InitO |
| 25 | .connection = .{ | 26 | .connection = .{ |
| 26 | .stream = connection.stream, | 27 | .stream = connection.stream, |
| 27 | .protocol = .plain, | 28 | .protocol = .plain, |
| 28 | .closing = true, | | |
| 29 | .read_buf = undefined, | 29 | .read_buf = undefined, |
| 30 | .read_start = 0, | 30 | .read_start = 0, |
| 31 | .read_end = 0, | 31 | .read_end = 0, |
| 32 | }, | 32 | }, |
| | 33 | .connection_closing = true, |
| 33 | .request = Server.Request.init(options), | 34 | .request = Server.Request.init(options), |
| 34 | .version = .@"HTTP/1.1", | 35 | .version = .@"HTTP/1.1", |
| 35 | .status = .ok, | 36 | .status = .ok, |
| ... | @@ -232,7 +233,7 @@ pub fn reset(res: *Server) ResetState { | ... | @@ -232,7 +233,7 @@ pub fn reset(res: *Server) ResetState { |
| 232 | | 233 | |
| 233 | if (!res.request.parser.done) { | 234 | if (!res.request.parser.done) { |
| 234 | // If the response wasn't fully read, then we need to close the connection. | 235 | // If the response wasn't fully read, then we need to close the connection. |
| 235 | res.connection.closing = true; | 236 | res.connection_closing = true; |
| 236 | return .closing; | 237 | return .closing; |
| 237 | } | 238 | } |
| 238 | | 239 | |
| ... | @@ -240,7 +241,7 @@ pub fn reset(res: *Server) ResetState { | ... | @@ -240,7 +241,7 @@ pub fn reset(res: *Server) ResetState { |
| 240 | // and its value is not "close". The server and client must both agree. | 241 | // and its value is not "close". The server and client must both agree. |
| 241 | // | 242 | // |
| 242 | // send() defaults to using keep-alive if the client requests it. | 243 | // 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; |
| 244 | | 245 | |
| 245 | res.state = .start; | 246 | res.state = .start; |
| 246 | res.version = .@"HTTP/1.1"; | 247 | res.version = .@"HTTP/1.1"; |
| ... | @@ -253,7 +254,7 @@ pub fn reset(res: *Server) ResetState { | ... | @@ -253,7 +254,7 @@ pub fn reset(res: *Server) ResetState { |
| 253 | .client_header_buffer = res.request.parser.header_bytes_buffer, | 254 | .client_header_buffer = res.request.parser.header_bytes_buffer, |
| 254 | }); | 255 | }); |
| 255 | | 256 | |
| 256 | return if (res.connection.closing) .closing else .reset; | 257 | return if (res.connection_closing) .closing else .reset; |
| 257 | } | 258 | } |
| 258 | | 259 | |
| 259 | pub const SendError = Connection.WriteError || error{ | 260 | pub const SendError = Connection.WriteError || error{ |