@@ -868,7 +868,7 @@ pub const Request = struct {
868
868
fn onRedirectConnect (ctx : * Ctx , res : anyerror ! void ) ! void {
869
869
res catch | err | return ctx .pop (err );
870
870
// re-send request
871
- ctx .req .prepareSend (.{} ) catch | err | return ctx .pop (err );
871
+ ctx .req .prepareSend () catch | err | return ctx .pop (err );
872
872
ctx .req .connection .? .async_flush (ctx , onRedirectSend ) catch | err | return ctx .pop (err );
873
873
}
874
874
@@ -896,6 +896,8 @@ pub const Request = struct {
896
896
req .privileged_headers = &.{};
897
897
}
898
898
899
+ try ctx .push (onRedirectConnect );
900
+
899
901
// create a new connection for the redirected URI
900
902
ctx .data .conn = try req .client .allocator .create (Connection );
901
903
ctx .data .conn .* = .{
@@ -1490,20 +1492,18 @@ pub const Request = struct {
1490
1492
const location = req .response .location orelse
1491
1493
return error .HttpRedirectLocationMissing ;
1492
1494
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
+ };
1507
1507
} else {
1508
1508
req .response .skip = false ;
1509
1509
if (! req .response .parser .done ) {
0 commit comments