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...@@ -25,7 +25,6 @@ pub fn init(connection: std.net.Server.Connection, options: Server.Request.InitO
25 .keep_alive = true,25 .keep_alive = true,
26 .connection = .{26 .connection = .{
27 .stream = connection.stream,27 .stream = connection.stream,
28 .protocol = .plain,
29 .read_buf = undefined,28 .read_buf = undefined,
30 .read_start = 0,29 .read_start = 0,
31 .read_end = 0,30 .read_end = 0,
lib/std/http/Server/Connection.zig+3-14
...@@ -1,18 +1,13 @@...@@ -1,18 +1,13 @@
1stream: std.net.Stream,1stream: std.net.Stream,
2protocol: Protocol,
32
4read_buf: [buffer_size]u8,3read_buf: [buffer_size]u8,
5read_start: u16,4read_start: u16,
6read_end: u16,5read_end: u16,
76
8pub const buffer_size = std.crypto.tls.max_ciphertext_record_len;7pub const buffer_size = std.crypto.tls.max_ciphertext_record_len;
9pub const Protocol = enum { plain };
108
11pub fn rawReadAtLeast(conn: *Connection, buffer: []u8, len: usize) ReadError!usize {9pub fn rawReadAtLeast(conn: *Connection, buffer: []u8, len: usize) ReadError!usize {
12 return switch (conn.protocol) {10 return conn.stream.readAtLeast(buffer, len) catch |err| {
13 .plain => conn.stream.readAtLeast(buffer, len),
14 // .tls => conn.tls_client.readAtLeast(conn.stream, buffer, len),
15 } catch |err| {
16 switch (err) {11 switch (err) {
17 error.ConnectionResetByPeer, error.BrokenPipe => return error.ConnectionResetByPeer,12 error.ConnectionResetByPeer, error.BrokenPipe => return error.ConnectionResetByPeer,
18 else => return error.UnexpectedReadFailure,13 else => return error.UnexpectedReadFailure,
...@@ -91,20 +86,14 @@ pub fn reader(conn: *Connection) Reader {...@@ -91,20 +86,14 @@ pub fn reader(conn: *Connection) Reader {
91}86}
9287
93pub fn writeAll(conn: *Connection, buffer: []const u8) WriteError!void {88pub fn writeAll(conn: *Connection, buffer: []const u8) WriteError!void {
94 return switch (conn.protocol) {89 return conn.stream.writeAll(buffer) catch |err| switch (err) {
95 .plain => conn.stream.writeAll(buffer),
96 // .tls => return conn.tls_client.writeAll(conn.stream, buffer),
97 } catch |err| switch (err) {
98 error.BrokenPipe, error.ConnectionResetByPeer => return error.ConnectionResetByPeer,90 error.BrokenPipe, error.ConnectionResetByPeer => return error.ConnectionResetByPeer,
99 else => return error.UnexpectedWriteFailure,91 else => return error.UnexpectedWriteFailure,
100 };92 };
101}93}
10294
103pub fn write(conn: *Connection, buffer: []const u8) WriteError!usize {95pub fn write(conn: *Connection, buffer: []const u8) WriteError!usize {
104 return switch (conn.protocol) {96 return conn.stream.write(buffer) catch |err| switch (err) {
105 .plain => conn.stream.write(buffer),
106 // .tls => return conn.tls_client.write(conn.stream, buffer),
107 } catch |err| switch (err) {
108 error.BrokenPipe, error.ConnectionResetByPeer => return error.ConnectionResetByPeer,97 error.BrokenPipe, error.ConnectionResetByPeer => return error.ConnectionResetByPeer,
109 else => return error.UnexpectedWriteFailure,98 else => return error.UnexpectedWriteFailure,
110 };99 };