mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-05-06 17:51:36 +02:00
Implement setting http status codes.
This commit is contained in:
parent
e0b76706d9
commit
413e9efbc8
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include "http_session.h"
|
#include "http_session.h"
|
||||||
|
|
||||||
#include "session_manager.h"
|
|
||||||
#include "core/http/web_root.h"
|
#include "core/http/web_root.h"
|
||||||
|
#include "session_manager.h"
|
||||||
|
|
||||||
HTTPSession *Request::get_or_create_session() {
|
HTTPSession *Request::get_or_create_session() {
|
||||||
if (session) {
|
if (session) {
|
||||||
@ -38,6 +38,13 @@ const String Request::get_parameter(const String &key) const {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HTTPStatusCode Request::get_status_code() const {
|
||||||
|
return _status_code;
|
||||||
|
}
|
||||||
|
void Request::set_status_code(const HTTPStatusCode status_code) {
|
||||||
|
_status_code = status_code;
|
||||||
|
}
|
||||||
|
|
||||||
void Request::send_redirect(const String &location, const HTTPStatusCode status_code) {
|
void Request::send_redirect(const String &location, const HTTPStatusCode status_code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +122,7 @@ void Request::reset() {
|
|||||||
current_file_progress = 0;
|
current_file_progress = 0;
|
||||||
connection_closed = false;
|
connection_closed = false;
|
||||||
_full_path = "";
|
_full_path = "";
|
||||||
|
_status_code = HTTP_STATUS_CODE_200_OK;
|
||||||
|
|
||||||
head.clear();
|
head.clear();
|
||||||
body.clear();
|
body.clear();
|
||||||
|
@ -54,6 +54,9 @@ public:
|
|||||||
|
|
||||||
virtual const String get_parameter(const String &key) const;
|
virtual const String get_parameter(const String &key) const;
|
||||||
|
|
||||||
|
HTTPStatusCode get_status_code() const;
|
||||||
|
void set_status_code(const HTTPStatusCode status_code);
|
||||||
|
|
||||||
virtual void send_redirect(const String &location, const HTTPStatusCode status_code = HTTP_STATUS_CODE_302_FOUND);
|
virtual void send_redirect(const String &location, const HTTPStatusCode status_code = HTTP_STATUS_CODE_302_FOUND);
|
||||||
virtual void compile_body();
|
virtual void compile_body();
|
||||||
virtual void compile_and_send_body();
|
virtual void compile_and_send_body();
|
||||||
@ -93,6 +96,7 @@ public:
|
|||||||
virtual ~Request();
|
virtual ~Request();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
HTTPStatusCode _status_code;
|
||||||
String _full_path;
|
String _full_path;
|
||||||
Vector<String> _path_stack;
|
Vector<String> _path_stack;
|
||||||
uint32_t _path_stack_pointer;
|
uint32_t _path_stack_pointer;
|
||||||
|
@ -47,6 +47,7 @@ void DRequest::send() {
|
|||||||
|
|
||||||
_response_additional_setup(response);
|
_response_additional_setup(response);
|
||||||
|
|
||||||
|
response->setStatusCode(static_cast<const HttpStatusCode>(static_cast<const int>(_status_code)));
|
||||||
response->setBody(compiled_body);
|
response->setBody(compiled_body);
|
||||||
|
|
||||||
response->setExpiredTime(0);
|
response->setExpiredTime(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user