diff options
Diffstat (limited to 'src/zenhttp/servers/httpparser.cpp')
| -rw-r--r-- | src/zenhttp/servers/httpparser.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/zenhttp/servers/httpparser.cpp b/src/zenhttp/servers/httpparser.cpp index 6b987151a..c64134c95 100644 --- a/src/zenhttp/servers/httpparser.cpp +++ b/src/zenhttp/servers/httpparser.cpp @@ -2,6 +2,7 @@ #include "httpparser.h" +#include <zencore/except.h> #include <zencore/logging.h> #include <zencore/string.h> @@ -62,7 +63,6 @@ HttpRequestParser::ConsumeData(const char* InputData, size_t DataSize) ZEN_WARN("HTTP parser error {} ('{}'). Closing connection", http_errno_name(HttpErrno), http_errno_description(HttpErrno)); return ~0ull; } - return ConsumedBytes; } @@ -360,11 +360,41 @@ HttpRequestParser::OnMessageBegin() int HttpRequestParser::OnMessageComplete() { - m_Connection.HandleRequest(); - - ResetState(); - - return 0; + try + { + m_Connection.HandleRequest(); + ResetState(); + return 0; + } + catch (std::system_error& SystemError) + { + if (IsOOM(SystemError.code())) + { + ZEN_WARN("out of memory when processing http request: '{}'", SystemError.what()); + } + else if (IsOOD(SystemError.code())) + { + ZEN_WARN("out of disk space when processing http request: '{}'", SystemError.what()); + } + else + { + ZEN_ERROR("failed processing http request: '{}'", SystemError.what()); + } + ResetState(); + return 1; + } + catch (std::bad_alloc& BadAlloc) + { + ZEN_WARN("out of memory when processing http request: '{}'", BadAlloc.what()); + ResetState(); + return 1; + } + catch (std::exception& Ex) + { + ZEN_ERROR("failed processing http request: '{}'", Ex.what()); + ResetState(); + return 1; + } } } // namespace zen |