@@ -868,7 +868,7 @@ pub const Request = struct {
868868 fn onRedirectConnect (ctx : * Ctx , res : anyerror ! void ) ! void {
869869 res catch | err | return ctx .pop (err );
870870 // re-send request
871- ctx .req .prepareSend (.{} ) catch | err | return ctx .pop (err );
871+ ctx .req .prepareSend () catch | err | return ctx .pop (err );
872872 ctx .req .connection .? .async_flush (ctx , onRedirectSend ) catch | err | return ctx .pop (err );
873873 }
874874
@@ -896,6 +896,8 @@ pub const Request = struct {
896896 req .privileged_headers = &.{};
897897 }
898898
899+ try ctx .push (onRedirectConnect );
900+
899901 // create a new connection for the redirected URI
900902 ctx .data .conn = try req .client .allocator .create (Connection );
901903 ctx .data .conn .* = .{
@@ -1490,20 +1492,18 @@ pub const Request = struct {
14901492 const location = req .response .location orelse
14911493 return error .HttpRedirectLocationMissing ;
14921494
1493- // This mutates the beginning of header_bytes_buffer and uses that
1494- // for the backing memory of the returned Uri.
1495- try req .redirect (req .uri .resolve_inplace (
1496- location ,
1497- & req .response .parser .header_bytes_buffer ,
1498- ) catch | err | switch (err ) {
1499- error .UnexpectedCharacter ,
1500- error .InvalidFormat ,
1501- error .InvalidPort ,
1502- = > return error .HttpRedirectLocationInvalid ,
1503- error .NoSpaceLeft = > return error .HttpHeadersOversize ,
1504- });
1505-
1506- return .{ .redirect_uri = req .uri };
1495+ return .{
1496+ .redirect_uri = req .uri .resolve_inplace (
1497+ location ,
1498+ & req .response .parser .header_bytes_buffer ,
1499+ ) catch | err | switch (err ) {
1500+ error .UnexpectedCharacter ,
1501+ error .InvalidFormat ,
1502+ error .InvalidPort ,
1503+ = > return error .HttpRedirectLocationInvalid ,
1504+ error .NoSpaceLeft = > return error .HttpHeadersOversize ,
1505+ },
1506+ };
15071507 } else {
15081508 req .response .skip = false ;
15091509 if (! req .response .parser .done ) {
0 commit comments