diff options
| author | Stefan Boberg <[email protected]> | 2022-06-16 15:32:00 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2022-06-16 15:32:00 +0200 |
| commit | 34b794663ca1f1be4a53c3ad44540396ea082698 (patch) | |
| tree | 3998d44a29fe9c77adede94e5978a3d33d7e91b0 /zenhttp/httpasio.cpp | |
| parent | trivial: removed some unnecessary WriteToString in unit tests (diff) | |
| download | zen-34b794663ca1f1be4a53c3ad44540396ea082698.tar.xz zen-34b794663ca1f1be4a53c3ad44540396ea082698.zip | |
asio: added some context to error reporting
Diffstat (limited to 'zenhttp/httpasio.cpp')
| -rw-r--r-- | zenhttp/httpasio.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/zenhttp/httpasio.cpp b/zenhttp/httpasio.cpp index 1ca5fb1c1..5c89b10f1 100644 --- a/zenhttp/httpasio.cpp +++ b/zenhttp/httpasio.cpp @@ -634,9 +634,11 @@ HttpRequest::ConsumeData(const char* InputData, size_t DataSize) { const size_t ConsumedBytes = http_parser_execute(&m_Parser, &s_ParserSettings, InputData, DataSize); - if (m_Parser.http_errno && m_Parser.http_errno != HPE_INVALID_EOF_STATE) + http_errno HttpErrno = HTTP_PARSER_ERRNO((&m_Parser)); + + if (HttpErrno && HttpErrno != HPE_INVALID_EOF_STATE) { - ZEN_WARN("HTTP parser error {}. Closing connection", (uint32_t)m_Parser.http_errno); + ZEN_WARN("HTTP parser error {} ('{}'). Closing connection", http_errno_name(HttpErrno), http_errno_description(HttpErrno)); TerminateConnection(); return DataSize; } @@ -850,6 +852,10 @@ HttpRequest::OnHeadersComplete() case HTTP_OPTIONS: m_RequestVerb = HttpVerb::kOptions; break; + + default: + ZEN_WARN("invalid HTTP method: '{}'", http_method_str(m_Parser.method)) + break; } std::string_view Url(m_Url, m_UrlLength); |