2021-06-20 17:53:07 +02:00
|
|
|
#ifndef DREQUEST_H
|
2021-07-06 16:57:21 +02:00
|
|
|
#define DREQUEST_H
|
2021-06-20 17:53:07 +02:00
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
#include "core/string.h"
|
|
|
|
#include "core/containers/vector.h"
|
|
|
|
|
2022-02-05 15:30:48 +01:00
|
|
|
#include "web/http/request.h"
|
2021-07-06 20:06:38 +02:00
|
|
|
|
2021-06-20 17:53:07 +02:00
|
|
|
#include <mutex>
|
|
|
|
|
2021-07-06 16:57:21 +02:00
|
|
|
#include "http/HttpRequestImpl.h"
|
2021-06-20 18:41:09 +02:00
|
|
|
#include "http/HttpResponse.h"
|
2021-06-20 17:53:07 +02:00
|
|
|
|
2021-08-04 15:36:26 +02:00
|
|
|
//using namespace drogon;
|
2021-06-20 18:41:09 +02:00
|
|
|
|
2022-01-07 20:14:07 +01:00
|
|
|
class DrogonWebServer;
|
2021-06-20 17:53:07 +02:00
|
|
|
|
2021-07-06 20:06:38 +02:00
|
|
|
class DRequest : public Request {
|
2021-06-20 17:53:07 +02:00
|
|
|
public:
|
2021-08-04 15:36:26 +02:00
|
|
|
drogon::HttpRequestImplPtr request;
|
|
|
|
std::function<void(const drogon::HttpResponsePtr &)> callback;
|
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
const String get_cookie(const String &key);
|
2021-08-04 15:36:26 +02:00
|
|
|
void add_cookie(const ::Cookie &cookie);
|
2021-11-01 19:11:27 +01:00
|
|
|
void remove_cookie(const String &key);
|
2021-07-06 16:57:21 +02:00
|
|
|
|
2021-08-05 17:11:13 +02:00
|
|
|
HTTPMethod get_method() const;
|
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
const String get_parameter(const String &key) const;
|
2021-08-05 18:24:55 +02:00
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
void send_redirect(const String &location, const HTTPStatusCode status_code = HTTP_STATUS_CODE_302_FOUND);
|
2021-06-20 17:53:07 +02:00
|
|
|
void send();
|
2021-11-01 19:11:27 +01:00
|
|
|
void send_file(const String &p_file_path);
|
2021-06-20 17:53:07 +02:00
|
|
|
void reset();
|
2021-11-01 19:11:27 +01:00
|
|
|
String parser_get_path();
|
|
|
|
String get_host() const;
|
2021-06-20 17:53:07 +02:00
|
|
|
|
|
|
|
void update();
|
|
|
|
|
2021-07-06 20:06:38 +02:00
|
|
|
static DRequest *get();
|
|
|
|
static void pool(DRequest *request);
|
|
|
|
void pool();
|
|
|
|
|
2021-06-20 17:53:07 +02:00
|
|
|
DRequest();
|
|
|
|
~DRequest();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _progress_send_file();
|
|
|
|
void _file_chunk_sent();
|
2021-08-04 15:36:26 +02:00
|
|
|
void _response_additional_setup(const drogon::HttpResponsePtr &req);
|
2021-06-20 17:53:07 +02:00
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
Vector<::Cookie> _added_cookies;
|
|
|
|
Vector<String> _removed_cookies;
|
2021-08-04 15:36:26 +02:00
|
|
|
|
2021-07-06 20:06:38 +02:00
|
|
|
private:
|
|
|
|
static RequestPool<DRequest> _request_pool;
|
2021-06-20 17:53:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|