mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-19 19:16:23 +01:00
Added optional protocol error logging to HTTPParser. Also remove unnecessary error.
This commit is contained in:
parent
8b4fc877a0
commit
4ededb6a34
@ -2,11 +2,14 @@
|
||||
|
||||
#include "./http_parser/http_parser.h"
|
||||
#include "./multipart_parser_c/multipart_parser.h"
|
||||
#include "core/log/logger.h"
|
||||
|
||||
#include "modules/web/http/web_server_request.h"
|
||||
|
||||
#include "simple_web_server_request.h"
|
||||
|
||||
#define PROTOCOL_ERROR_LOGGING_ENABLED 0
|
||||
|
||||
Ref<SimpleWebServerRequest> HTTPParser::get_next_request() {
|
||||
ERR_FAIL_COND_V(_requests.size() == 0, Ref<SimpleWebServerRequest>());
|
||||
|
||||
@ -234,6 +237,9 @@ int HTTPParser::on_message_begin() {
|
||||
default:
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_INVALID);
|
||||
_error = true;
|
||||
#if PROTOCOL_ERROR_LOGGING_ENABLED
|
||||
PLOG_ERR("Unimplemented / invalid method!");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@ -307,6 +313,9 @@ int HTTPParser::on_header_value(const char *at, size_t length) {
|
||||
if (bs == -1) {
|
||||
//Error! boundary must exist
|
||||
_error = true;
|
||||
#if PROTOCOL_ERROR_LOGGING_ENABLED
|
||||
PLOG_ERR("Boundary must exist!");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -321,7 +330,9 @@ int HTTPParser::on_header_value(const char *at, size_t length) {
|
||||
//The CRLF preceeding could also be appended for simpler logic
|
||||
|
||||
if (_multipart_boundary.empty()) {
|
||||
//Error!
|
||||
#if PROTOCOL_ERROR_LOGGING_ENABLED
|
||||
PLOG_ERR("Empty boundary!");
|
||||
#endif
|
||||
_error = true;
|
||||
}
|
||||
|
||||
@ -346,8 +357,6 @@ int HTTPParser::on_header_value(const char *at, size_t length) {
|
||||
}
|
||||
}
|
||||
|
||||
_error = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
int HTTPParser::on_headers_complete() {
|
||||
|
Loading…
Reference in New Issue
Block a user