authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-18 20:27:49-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-23 02:37:11-07:00
log968d08af6db476942c60d17d55e3086ec0736fac
tree698545e9ac3183580a45c86816a8959270707714
parentc7fc2d76ce2b9b1cedd6d71232f31ba9556f05d9

std.http.Server.Connection: remove dead code


2 files changed, 3 insertions(+), 15 deletions(-)

lib/std/http/Server.zig-1
......@@ -25,7 +25,6 @@ pub fn init(connection: std.net.Server.Connection, options: Server.Request.InitO
2525 .keep_alive = true,
2626 .connection = .{
2727 .stream = connection.stream,
28 .protocol = .plain,
2928 .read_buf = undefined,
3029 .read_start = 0,
3130 .read_end = 0,
lib/std/http/Server/Connection.zig+3-14
......@@ -1,18 +1,13 @@
11stream: std.net.Stream,
2protocol: Protocol,
32
43read_buf: [buffer_size]u8,
54read_start: u16,
65read_end: u16,
76
87pub const buffer_size = std.crypto.tls.max_ciphertext_record_len;
9pub const Protocol = enum { plain };
108
119pub fn rawReadAtLeast(conn: *Connection, buffer: []u8, len: usize) ReadError!usize {
12 return switch (conn.protocol) {
13 .plain => conn.stream.readAtLeast(buffer, len),
14 // .tls => conn.tls_client.readAtLeast(conn.stream, buffer, len),
15 } catch |err| {
10 return conn.stream.readAtLeast(buffer, len) catch |err| {
1611 switch (err) {
1712 error.ConnectionResetByPeer, error.BrokenPipe => return error.ConnectionResetByPeer,
1813 else => return error.UnexpectedReadFailure,
......@@ -91,20 +86,14 @@ pub fn reader(conn: *Connection) Reader {
9186}
9287
9388pub fn writeAll(conn: *Connection, buffer: []const u8) WriteError!void {
94 return switch (conn.protocol) {
95 .plain => conn.stream.writeAll(buffer),
96 // .tls => return conn.tls_client.writeAll(conn.stream, buffer),
97 } catch |err| switch (err) {
89 return conn.stream.writeAll(buffer) catch |err| switch (err) {
9890 error.BrokenPipe, error.ConnectionResetByPeer => return error.ConnectionResetByPeer,
9991 else => return error.UnexpectedWriteFailure,
10092 };
10193}
10294
10395pub fn write(conn: *Connection, buffer: []const u8) WriteError!usize {
104 return switch (conn.protocol) {
105 .plain => conn.stream.write(buffer),
106 // .tls => return conn.tls_client.write(conn.stream, buffer),
107 } catch |err| switch (err) {
96 return conn.stream.write(buffer) catch |err| switch (err) {
10897 error.BrokenPipe, error.ConnectionResetByPeer => return error.ConnectionResetByPeer,
10998 else => return error.UnexpectedWriteFailure,
11099 };