mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Support HTTP headers which are \n terminated (as opposed to \r\n).
Looks like curl will accept these as valid headers, and won't normalize the header, so we have to deal with either a 2-byte or 1-byte terminated header
This commit is contained in:
@@ -1402,10 +1402,22 @@ pub const Transfer = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (comptime IS_DEBUG) {
|
if (comptime IS_DEBUG) {
|
||||||
std.debug.assert(std.mem.endsWith(u8, buffer[0..buf_len], "\r\n"));
|
// curl will allow header lines that end with either \r\n or just \n
|
||||||
|
std.debug.assert(buffer[buf_len - 1] == '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
const header = buffer[0 .. buf_len - 2];
|
if (buf_len < 3) {
|
||||||
|
// could be \r\n or \n.
|
||||||
|
return buf_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
var header_len = buf_len - 2;
|
||||||
|
if (buffer[buf_len - 2] != '\r') {
|
||||||
|
// curl supports headers that just end with either \r\n or \n
|
||||||
|
header_len = buf_len - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const header = buffer[0 .. header_len];
|
||||||
|
|
||||||
// We need to parse the first line headers for each request b/c curl's
|
// We need to parse the first line headers for each request b/c curl's
|
||||||
// CURLINFO_RESPONSE_CODE returns the status code of the final request.
|
// CURLINFO_RESPONSE_CODE returns the status code of the final request.
|
||||||
@@ -1462,7 +1474,7 @@ pub const Transfer = struct {
|
|||||||
transfer.bytes_received += buf_len;
|
transfer.bytes_received += buf_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf_len != 2) {
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user