diff options
| author | Stefan Boberg <[email protected]> | 2024-03-05 14:06:13 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-05 14:06:13 +0100 |
| commit | 1c5fadd56944c3aedefaf6065bbce4a028e620e4 (patch) | |
| tree | 6078f2b10c1b66b4ca7fbc7c81144115b1a458e7 /src/zenhttp/servers/httpasio.cpp | |
| parent | 5.4.2-pre0 (diff) | |
| download | zen-1c5fadd56944c3aedefaf6065bbce4a028e620e4.tar.xz zen-1c5fadd56944c3aedefaf6065bbce4a028e620e4.zip | |
some asio HTTP server tweaks for correctness (#663)
Diffstat (limited to 'src/zenhttp/servers/httpasio.cpp')
| -rw-r--r-- | src/zenhttp/servers/httpasio.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/zenhttp/servers/httpasio.cpp b/src/zenhttp/servers/httpasio.cpp index 6b45c259d..c75057733 100644 --- a/src/zenhttp/servers/httpasio.cpp +++ b/src/zenhttp/servers/httpasio.cpp @@ -293,7 +293,7 @@ HttpServerConnection::TerminateConnection() void HttpServerConnection::EnqueueRead() { - if (m_RequestState == RequestState::kInitialRead) + if ((m_RequestState == RequestState::kInitialRead) || (m_RequestState == RequestState::kReadingMore)) { m_RequestState = RequestState::kReadingMore; } @@ -315,15 +315,17 @@ HttpServerConnection::OnDataReceived(const asio::error_code& Ec, [[maybe_unused] { if (Ec) { - if (m_RequestState == RequestState::kDone || m_RequestState == RequestState::kInitialRead) + switch (m_RequestState) { - ZEN_TRACE_VERBOSE("on data received ERROR (EXPECTED), connection: {}, reason: '{}'", m_ConnectionId, Ec.message()); - return; - } - else - { - ZEN_WARN("on data received ERROR, connection: {}, reason '{}'", m_ConnectionId, Ec.message()); - return TerminateConnection(); + case RequestState::kDone: + case RequestState::kInitialRead: + case RequestState::kTerminated: + ZEN_TRACE_VERBOSE("on data received ERROR (EXPECTED), connection: {}, reason: '{}'", m_ConnectionId, Ec.message()); + return; + + default: + ZEN_WARN("on data received ERROR, connection: {}, reason '{}'", m_ConnectionId, Ec.message()); + return TerminateConnection(); } } |