mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1567 from lightpanda-io/http_linefeed_only_ending
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Support HTTP headers which are \n terminated (as opposed to \r\n).
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