From e020ecec1596192b6e6ffe8453094e37e95a85ef Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 30 Sep 2023 22:59:42 -0700 Subject: Fix bug causing "Connection Refused" errors (#6206) * Loop through the return values of getaddrinfo * Remove incorrect assertion * Remove extra check * Remove extra check * Update bsd.c * More consistent --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/http_client_async.zig | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/http_client_async.zig b/src/http_client_async.zig index 1e0ba7cc0..6c731acd5 100644 --- a/src/http_client_async.zig +++ b/src/http_client_async.zig @@ -1343,7 +1343,7 @@ pub const InternalState = struct { return this.transfer_encoding == Encoding.chunked; } - pub fn reset(this: *InternalState, buffering: bool, allocator: std.mem.Allocator) void { + pub fn reset(this: *InternalState, allocator: std.mem.Allocator) void { this.compressed_body.deinit(); this.response_message_buffer.deinit(); @@ -1354,12 +1354,6 @@ pub const InternalState = struct { reader.deinit(); } - if (!buffering) { - // if we are holding a cloned_metadata we need to deinit it - // this should never happen because we should always return the metadata to the user - std.debug.assert(this.cloned_metadata == null); - } - // just in case we check and free to avoid leaks if (this.cloned_metadata != null) { this.cloned_metadata.?.deinit(allocator); @@ -2186,7 +2180,7 @@ pub fn doRedirect(this: *HTTPClient) void { this.fail(error.TooManyRedirects); return; } - this.state.reset(this.signals.isEmpty(), this.allocator); + this.state.reset(this.allocator); // also reset proxy to redirect this.proxy_tunneling = false; if (this.proxy_tunnel != null) { @@ -2907,7 +2901,7 @@ fn fail(this: *HTTPClient, err: anyerror) void { _ = socket_async_http_abort_tracker.swapRemove(this.async_http_id); } - this.state.reset(this.signals.isEmpty(), this.allocator); + this.state.reset(this.allocator); this.proxy_tunneling = false; this.state.request_stage = .fail; @@ -2993,7 +2987,7 @@ pub fn progressUpdate(this: *HTTPClient, comptime is_ssl: bool, ctx: *NewHTTPCon socket.close(0, null); } - this.state.reset(this.signals.isEmpty(), this.allocator); + this.state.reset(this.allocator); this.state.response_stage = .done; this.state.request_stage = .done; this.state.stage = .done; -- cgit v1.2.3