mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.http: header whitespace is optional, and not part of value
This commit is contained in:
parent
69bcdbefd0
commit
81713f20a6
3 changed files with 6 additions and 6 deletions
|
|
@ -489,9 +489,9 @@ pub const Response = struct {
|
|||
else => {},
|
||||
}
|
||||
|
||||
var line_it = mem.splitSequence(u8, line, ": ");
|
||||
var line_it = mem.splitScalar(u8, line, ':');
|
||||
const header_name = line_it.next().?;
|
||||
const header_value = line_it.rest();
|
||||
const header_value = mem.trim(u8, line_it.rest(), " \t");
|
||||
if (header_name.len == 0) return error.HttpHeadersInvalid;
|
||||
|
||||
if (std.ascii.eqlIgnoreCase(header_name, "connection")) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub fn next(it: *HeaderIterator) ?std.http.Header {
|
|||
}
|
||||
|
||||
test next {
|
||||
var it = HeaderIterator.init("200 OK\r\na: b\r\nc: \r\nd: e\r\n\r\nf: g\r\n\r\n");
|
||||
var it = HeaderIterator.init("200 OK\r\na: b\r\nc: \r\nd:e\r\n\r\nf: g\r\n\r\n");
|
||||
try std.testing.expect(!it.is_trailer);
|
||||
{
|
||||
const header = it.next().?;
|
||||
|
|
@ -80,7 +80,7 @@ test next {
|
|||
try std.testing.expect(!it.is_trailer);
|
||||
try std.testing.expectEqual(null, it.next());
|
||||
|
||||
it = HeaderIterator.init("200 OK\r\na: b\r\n\r\n: ss\r\n\r\n");
|
||||
it = HeaderIterator.init("200 OK\r\na:b\r\n\r\n: ss\r\n\r\n");
|
||||
try std.testing.expect(!it.is_trailer);
|
||||
{
|
||||
const header = it.next().?;
|
||||
|
|
|
|||
|
|
@ -211,9 +211,9 @@ pub const Request = struct {
|
|||
else => {},
|
||||
}
|
||||
|
||||
var line_it = mem.splitSequence(u8, line, ": ");
|
||||
var line_it = mem.splitScalar(u8, line, ':');
|
||||
const header_name = line_it.next().?;
|
||||
const header_value = line_it.rest();
|
||||
const header_value = mem.trim(u8, line_it.rest(), " \t");
|
||||
if (header_name.len == 0) return error.HttpHeadersInvalid;
|
||||
|
||||
if (std.ascii.eqlIgnoreCase(header_name, "connection")) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue