Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTP header parse for space #158

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion net/http/headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ int HeadersBase::parse() {
Parser p({m_buf, m_buf_size});
while(p[0] != '\r') {
auto k = p.extract_until_char(':');
p.skip_string(": ");
p.skip_chars(':');
p.skip_chars(' ', true);
auto v = p.extract_until_char('\r');
p.skip_string("\r\n");
if (kv_add({k, v}) == nullptr)
Expand Down
8 changes: 6 additions & 2 deletions net/http/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ class Parser {
{
if (estring_view(_ptr, _end - _ptr).starts_with(sv)) _ptr += sv.length();
}
void skip_chars(char c)
void skip_chars(char c, bool continuously = false)
{
if (*_ptr == c) _ptr++;
while (*_ptr == c) {
_ptr++;
if (!continuously)
return;
}
}
void skip_until_string(const std::string& s)
{
Expand Down