mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-21 20:24:42 +00:00
parse cookies on redirection during header callback
THe change to handle bot `\n` and `\r\n` for end HTTP headers skip the cookie parsing in case of redirection.
This commit is contained in:
@@ -1286,6 +1286,16 @@ pub const Transfer = struct {
|
|||||||
|
|
||||||
if (buf_len < 3) {
|
if (buf_len < 3) {
|
||||||
// could be \r\n or \n.
|
// 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;
|
return buf_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1352,38 +1362,22 @@ pub const Transfer = struct {
|
|||||||
transfer.bytes_received += buf_len;
|
transfer.bytes_received += buf_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf_len > 2) {
|
if (transfer._auth_challenge != null) {
|
||||||
if (transfer._auth_challenge != null) {
|
// try to parse auth challenge.
|
||||||
// try to parse auth challenge.
|
if (std.ascii.startsWithIgnoreCase(header, "WWW-Authenticate") or
|
||||||
if (std.ascii.startsWithIgnoreCase(header, "WWW-Authenticate") or
|
std.ascii.startsWithIgnoreCase(header, "Proxy-Authenticate"))
|
||||||
std.ascii.startsWithIgnoreCase(header, "Proxy-Authenticate"))
|
{
|
||||||
{
|
const ac = AuthChallenge.parse(
|
||||||
const ac = AuthChallenge.parse(
|
transfer._auth_challenge.?.status,
|
||||||
transfer._auth_challenge.?.status,
|
header,
|
||||||
header,
|
) catch |err| {
|
||||||
) catch |err| {
|
// We can't parse the auth challenge
|
||||||
// We can't parse the auth challenge
|
log.err(.http, "parse auth challenge", .{ .err = err, .header = header });
|
||||||
log.err(.http, "parse auth challenge", .{ .err = err, .header = header });
|
// Should we cancel the request? I don't think so.
|
||||||
// Should we cancel the request? I don't think so.
|
return buf_len;
|
||||||
return buf_len;
|
};
|
||||||
};
|
transfer._auth_challenge = ac;
|
||||||
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;
|
return buf_len;
|
||||||
|
|||||||
Reference in New Issue
Block a user