mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-13 22:31:11 +01:00
Now the SimpleWebServer will properly set the Request's http method.
This commit is contained in:
parent
e52a188794
commit
0854b8999d
@ -299,6 +299,34 @@ int HTTPParser::on_message_begin() {
|
||||
|
||||
_request.instance();
|
||||
|
||||
switch (parser->method) {
|
||||
case http_method::HTTP_DELETE:
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_DELETE);
|
||||
break;
|
||||
case http_method::HTTP_GET:
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_GET);
|
||||
break;
|
||||
case http_method::HTTP_HEAD:
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_HEAD);
|
||||
break;
|
||||
case http_method::HTTP_POST:
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_POST);
|
||||
break;
|
||||
case http_method::HTTP_PUT:
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_PUT);
|
||||
break;
|
||||
case http_method::HTTP_OPTIONS:
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_OPTIONS);
|
||||
break;
|
||||
case http_method::HTTP_PATCH:
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_PATCH);
|
||||
break;
|
||||
default:
|
||||
//TODO close the connection
|
||||
_request->set_method(HTTPServerEnums::HTTP_METHOD_INVALID);
|
||||
break;
|
||||
}
|
||||
|
||||
#if MESSAGE_DEBUG
|
||||
ERR_PRINT("begin");
|
||||
#endif
|
||||
|
@ -24,7 +24,7 @@ String SimpleWebServerRequest::get_cookie(const String &key) {
|
||||
}
|
||||
|
||||
HTTPServerEnums::HTTPMethod SimpleWebServerRequest::get_method() const {
|
||||
return HTTPServerEnums::HTTP_METHOD_GET;
|
||||
return _method;
|
||||
}
|
||||
|
||||
void SimpleWebServerRequest::parse_files() {
|
||||
@ -136,8 +136,13 @@ void SimpleWebServerRequest::add_cookie_data(const String &key, const String &va
|
||||
_cookies.push_back(d);
|
||||
}
|
||||
|
||||
void SimpleWebServerRequest::set_method(const HTTPServerEnums::HTTPMethod method) {
|
||||
_method = method;
|
||||
}
|
||||
|
||||
SimpleWebServerRequest::SimpleWebServerRequest() {
|
||||
_server = nullptr;
|
||||
_method = HTTPServerEnums::HTTP_METHOD_GET;
|
||||
}
|
||||
|
||||
SimpleWebServerRequest::~SimpleWebServerRequest() {
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
|
||||
void add_cookie_data(const String &key, const String &value);
|
||||
|
||||
void set_method(const HTTPServerEnums::HTTPMethod method);
|
||||
|
||||
//virtual String get_path_full() const;
|
||||
|
||||
SimpleWebServerRequest();
|
||||
@ -77,6 +79,7 @@ protected:
|
||||
};
|
||||
|
||||
Vector<CookieData> _cookies;
|
||||
HTTPServerEnums::HTTPMethod _method;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user