MySQL 9.1.0
Source Code Documentation
request.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef ROUTER_SRC_HTTP_INCLUDE_HTTP_BASE_REQUEST_H_
27#define ROUTER_SRC_HTTP_INCLUDE_HTTP_BASE_REQUEST_H_
28
29#include <cassert>
30#include <string>
31
33#include "http/base/headers.h"
34#include "http/base/io_buffer.h"
35#include "http/base/method.h"
37#include "http/base/uri.h"
38
40
41namespace http {
42namespace base {
43
45 public:
52
53 public:
54 virtual ~Request() = default;
55
56 // Informations that we received from other side
57 // In case of:
58 // * server, they are Request data
59 // * client, they are Response data
60 virtual const Headers &get_input_headers() const = 0;
61 virtual IOBuffer &get_input_buffer() const = 0;
62 virtual const std::string &get_input_body() const = 0;
63
66
67 virtual StatusType get_response_code() const {
68 assert(false &&
69 "Unsupported in current derived class of `http::base::Request`");
71 }
72 // std::string get_response_code_line() const = 0;
73
74 virtual void set_method(MethodType) {
75 assert(false &&
76 "Unsupported in current derived class of `http::base::Request`");
77 }
78
79 virtual MethodType get_method() const {
80 assert(false &&
81 "Unsupported in current derived class of `http::base::Request`");
82
83 return {};
84 }
85
86 virtual void set_uri([[maybe_unused]] Uri &&uri) {
87 assert(false &&
88 "Unsupported in current derived class of `http::base::Request`");
89 }
90
91 virtual void set_uri([[maybe_unused]] const Uri &uri) {
92 assert(false &&
93 "Unsupported in current derived class of `http::base::Request`");
94 }
95
96 virtual const Uri &get_uri() const = 0;
97
98 virtual void send_reply([[maybe_unused]] StatusType status_code) {
99 assert(false &&
100 "Unsupported in current derived class of `http::base::Request`");
101 }
102
103 virtual void send_reply([[maybe_unused]] StatusType status_code,
104 [[maybe_unused]] const std::string &status_text) {
105 assert(false &&
106 "Unsupported in current derived class of `http::base::Request`");
107 }
108
109 virtual void send_reply([[maybe_unused]] StatusType status_code,
110 [[maybe_unused]] const std::string &status_text,
111 [[maybe_unused]] const IOBuffer &buffer) {
112 assert(false &&
113 "Unsupported in current derived class of `http::base::Request`");
114 }
115
116 virtual void send_error([[maybe_unused]] StatusType status_code) {
117 assert(false &&
118 "Unsupported in current derived class of `http::base::Request`");
119 }
120
121 virtual void send_error([[maybe_unused]] StatusType status_code,
122 [[maybe_unused]] const std::string &status_text) {
123 assert(false &&
124 "Unsupported in current derived class of `http::base::Request`");
125 }
126
127 /**
128 * is request modified since 'last_modified'.
129 *
130 * @return true, if local content is newer than the clients last known date,
131 * false otherwise
132 */
133 virtual bool is_modified_since([[maybe_unused]] time_t last_modified) {
134 assert(false &&
135 "Unsupported in current derived class of `http::base::Request`");
136 return false;
137 }
138
139 /**
140 * add a Last-Modified-Since header to the response headers.
141 */
142 virtual bool add_last_modified([[maybe_unused]] time_t last_modified) {
143 assert(false &&
144 "Unsupported in current derived class of `http::base::Request`");
145 return false;
146 }
147
149};
150
151} // namespace base
152} // namespace http
153
154#endif // ROUTER_SRC_HTTP_INCLUDE_HTTP_BASE_REQUEST_H_
Definition: connection_interface.h:41
headers of a HTTP response/request.
Definition: headers.h:43
Definition: io_buffer.h:41
Definition: request.h:44
virtual void send_reply(StatusType status_code, const std::string &status_text, const IOBuffer &buffer)
Definition: request.h:109
virtual void set_uri(Uri &&uri)
Definition: request.h:86
virtual void send_reply(StatusType status_code, const std::string &status_text)
Definition: request.h:103
virtual IOBuffer & get_output_buffer()=0
virtual bool add_last_modified(time_t last_modified)
add a Last-Modified-Since header to the response headers.
Definition: request.h:142
virtual void send_reply(StatusType status_code)
Definition: request.h:98
virtual const std::string & get_input_body() const =0
virtual Headers & get_output_headers()=0
virtual const Uri & get_uri() const =0
virtual MethodType get_method() const
Definition: request.h:79
virtual ConnectionInterface * get_connection() const =0
virtual StatusType get_response_code() const
Definition: request.h:67
virtual void set_uri(const Uri &uri)
Definition: request.h:91
virtual IOBuffer & get_input_buffer() const =0
virtual void send_error(StatusType status_code, const std::string &status_text)
Definition: request.h:121
http::base::method::key_type MethodType
Definition: request.h:49
http::base::status_code::key_type StatusType
Definition: request.h:50
virtual ~Request()=default
virtual void send_error(StatusType status_code)
Definition: request.h:116
virtual const Headers & get_input_headers() const =0
virtual void set_method(MethodType)
Definition: request.h:74
virtual bool is_modified_since(time_t last_modified)
is request modified since 'last_modified'.
Definition: request.h:133
Definition: uri.h:38
#define HTTP_COMMON_EXPORT
Definition: http_common_export.h:15
int key_type
Definition: method.h:38
int key_type
Definition: status_code.h:36
constexpr key_type NotImplemented
Definition: status_code.h:94
Request::ConnectionInterface ConnectionInterface
Definition: request.cc:38
Request::IOBuffer IOBuffer
Definition: request.cc:33
Request::Headers Headers
Definition: request.cc:35
Request::Uri Uri
Definition: request.cc:37
Definition: connection.h:56
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418