Skip to content

Commit

Permalink
Fix HTTP header parse for space (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
beef9999 committed Jul 20, 2023
1 parent d334372 commit 378bc34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit 378bc34

Please sign in to comment.