mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Added http method support to the request class.
This commit is contained in:
parent
6ea8d3e39a
commit
543f1eed30
15
core/http/http_enums.h
Normal file
15
core/http/http_enums.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef HTTP_ENUMS_H
|
||||
#define HTTP_ENUMS_H
|
||||
|
||||
enum HTTPMethod {
|
||||
HTTP_METHOD_GET = 0,
|
||||
HTTP_METHOD_POST,
|
||||
HTTP_METHOD_HEAD,
|
||||
HTTP_METHOD_PUT,
|
||||
HTTP_METHOD_DELETE,
|
||||
HTTP_METHOD_OPTIONS,
|
||||
HTTP_METHOD_PATCH,
|
||||
HTTP_METHOD_INVALID,
|
||||
};
|
||||
|
||||
#endif
|
@ -14,6 +14,10 @@ void Request::add_cookie(const ::Cookie &cookie) {
|
||||
void Request::remove_cookie(const std::string &key) {
|
||||
}
|
||||
|
||||
HTTPMethod Request::get_method() const {
|
||||
return HTTP_METHOD_GET;
|
||||
}
|
||||
|
||||
void Request::compile_body() {
|
||||
compiled_body.reserve(body.size() + head.size() + 13 + 14 + 15);
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "handler_instance.h"
|
||||
|
||||
#include "http_enums.h"
|
||||
|
||||
class WebApplication;
|
||||
class Cookie;
|
||||
class HTTPSession;
|
||||
@ -41,6 +43,8 @@ public:
|
||||
virtual void add_cookie(const ::Cookie &cookie);
|
||||
virtual void remove_cookie(const std::string &key);
|
||||
|
||||
virtual HTTPMethod get_method() const;
|
||||
|
||||
virtual void compile_body();
|
||||
virtual void compile_and_send_body();
|
||||
virtual void next_stage();
|
||||
|
@ -14,6 +14,12 @@ void DRequest::remove_cookie(const std::string &key) {
|
||||
_removed_cookies.push_back(key);
|
||||
}
|
||||
|
||||
HTTPMethod DRequest::get_method() const {
|
||||
//the enums are in the same order
|
||||
|
||||
return static_cast<HTTPMethod>(static_cast<int>(request->getMethod()));
|
||||
}
|
||||
|
||||
void DRequest::send() {
|
||||
//if (connection_closed) {
|
||||
// DRequestPool::return_request(this);
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
void add_cookie(const ::Cookie &cookie);
|
||||
void remove_cookie(const std::string &key);
|
||||
|
||||
HTTPMethod get_method() const;
|
||||
|
||||
void send();
|
||||
void send_file(const std::string &p_file_path);
|
||||
void reset();
|
||||
|
Loading…
Reference in New Issue
Block a user