Merge pull request #1803 from lightpanda-io/fix-redirection-cookies

parse cookies on redirection during header callback
This commit is contained in:
Karl Seguin
2026-03-13 07:17:51 +08:00
committed by GitHub

View File

@@ -1286,6 +1286,16 @@ pub const Transfer = struct {
if (buf_len < 3) {
// could be \r\n or \n.
// We get the last header line.
if (transfer._redirecting) {
// parse and set cookies for the redirection.
redirectionCookies(transfer, &conn) catch |err| {
if (comptime IS_DEBUG) {
log.debug(.http, "redirection cookies", .{ .err = err });
}
return 0;
};
}
return buf_len;
}
@@ -1352,7 +1362,6 @@ pub const Transfer = struct {
transfer.bytes_received += buf_len;
}
if (buf_len > 2) {
if (transfer._auth_challenge != null) {
// try to parse auth challenge.
if (std.ascii.startsWithIgnoreCase(header, "WWW-Authenticate") or
@@ -1370,21 +1379,6 @@ pub const Transfer = struct {
transfer._auth_challenge = ac;
}
}
return buf_len;
}
// Starting here, we get the last header line.
if (transfer._redirecting) {
// parse and set cookies for the redirection.
redirectionCookies(transfer, &conn) catch |err| {
if (comptime IS_DEBUG) {
log.debug(.http, "redirection cookies", .{ .err = err });
}
return 0;
};
return buf_len;
}
return buf_len;
}