From d82728602bc3750687054f175731a671db0e487f Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 30 Aug 2023 13:40:08 -0700 Subject: [PATCH] fix failing test --- src/aws_http.zig | 3 ++- src/http_client_17015_issue.zig | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/aws_http.zig b/src/aws_http.zig index 66bde76..1e313d4 100644 --- a/src/aws_http.zig +++ b/src/aws_http.zig @@ -209,7 +209,8 @@ pub const AwsHttp = struct { defer req.deinit(); if (request_cp.body.len > 0) req.transfer_encoding = .{ .content_length = request_cp.body.len }; - try req.start(); + try @import("http_client_17015_issue.zig").start(&req); + // try req.start(); if (request_cp.body.len > 0) { try req.writeAll(request_cp.body); try req.finish(); diff --git a/src/http_client_17015_issue.zig b/src/http_client_17015_issue.zig index b380aea..3427f74 100644 --- a/src/http_client_17015_issue.zig +++ b/src/http_client_17015_issue.zig @@ -1,7 +1,5 @@ -const std = @import("../std.zig"); -const Uri = std.http.Uri; - -pub const StartError = std.http.Connection.WriteError || error{ InvalidContentLength, UnsupportedTransferEncoding }; +const std = @import("std"); +const Uri = std.Uri; /////////////////////////////////////////////////////////////////////////// /// This function imported from: @@ -12,7 +10,7 @@ pub const StartError = std.http.Connection.WriteError || error{ InvalidContentLe /// only the two w.print lines for req.uri 16 and 18 lines down from this comment /////////////////////////////////////////////////////////////////////////// /// Send the request to the server. -pub fn start(req: *std.http.Client.Request) StartError!void { +pub fn start(req: *std.http.Client.Request) std.http.Client.Request.StartError!void { var buffered = std.io.bufferedWriter(req.connection.?.data.writer()); const w = buffered.writer(); @@ -25,9 +23,9 @@ pub fn start(req: *std.http.Client.Request) StartError!void { try w.print("{}", .{req.uri.port.?}); } else if (req.connection.?.data.proxied) { // proxied connections require the full uri - try w.print("{+/}", .{req.uri}); + try format(req.uri, "+/", .{}, w); } else { - try w.print("{/}", .{req.uri}); + try format(req.uri, "/", .{}, w); } try w.writeByte(' '); @@ -139,7 +137,7 @@ pub fn format( if (uri.path.len == 0) { try writer.writeAll("/"); } else { - try Uri.writeEscapedPath(writer, uri.path); + try writer.writeAll(uri.path); // do not mess with our path } if (uri.query) |q| {