Kea 2.7.5
request.h
Go to the documentation of this file.
1// Copyright (C) 2016-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef HTTP_REQUEST_H
8#define HTTP_REQUEST_H
9
11#include <http/basic_auth.h>
12#include <http/http_message.h>
14#include <boost/shared_ptr.hpp>
15#include <cstdint>
16
17namespace isc {
18namespace http {
19
22public:
23 HttpRequestError(const char* file, size_t line, const char* what) :
24 HttpMessageError(file, line, what) { }
25};
26
27class HttpRequest;
28
30typedef boost::shared_ptr<HttpRequest> HttpRequestPtr;
31
58public:
59
71
74
87 HttpRequest(const Method& method, const std::string& uri, const HttpVersion& version,
88 const HostHttpHeader& host_header = HostHttpHeader(),
89 const BasicHttpAuthPtr& basic_auth = BasicHttpAuthPtr());
90
99 return (context_);
100 }
101
106 std::string getRemote() const {
107 return (remote_);
108 }
109
113 void setRemote(const std::string& remote) {
114 remote_ = remote;
115 }
116
123 void requireHttpMethod(const HttpRequest::Method& method);
124
134 virtual void create();
135
141 virtual void finalize();
142
144 virtual void reset();
145
147 Method getMethod() const;
148
150 std::string getUri() const;
151
152
154 std::string getBody() const;
155
157 std::string toBriefString() const;
158
163 virtual std::string toString() const;
164
174 bool isPersistent() const;
175
177
181 bool getTls() const {
182 return (tls_);
183 }
184
188 void setTls(bool tls) {
189 tls_ = tls;
190 }
191
195 std::string getSubject() const {
196 return (subject_);
197 }
198
202 void setSubject(const std::string& subject) {
203 subject_ = subject;
204 }
205
209 std::string getIssuer() const {
210 return (issuer_);
211 }
212
216 void setIssuer(const std::string& issuer) {
217 issuer_ = issuer;
218 }
219
223 std::string getBasicAuth() const {
224 return (basic_auth_);
225 }
226
230 void setBasicAuth(const std::string& basic_auth) {
231 basic_auth_ = basic_auth;
232 }
233
237 std::string getCustom() const {
238 return (custom_);
239 }
240
244 void setCustom(const std::string& custom) {
245 custom_ = custom;
246 }
247
250
252 static bool recordSubject_;
253
255 static bool recordIssuer_;
256
258 static bool recordBasicAuth_;
259
260protected:
261
269 Method methodFromString(std::string method) const;
270
276 std::string methodToString(const HttpRequest::Method& method) const;
277
281 std::set<Method> required_methods_;
282
285
289
291 std::string remote_;
292
294 bool tls_;
295
297 std::string subject_;
298
300 std::string issuer_;
301
303 std::string basic_auth_;
304
306 std::string custom_;
307};
308
309}
310}
311
312#endif
int version()
returns Kea hooks version.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Base class for classes which need to be associated with a CalloutHandle object.
Represents HTTP Host header.
Definition http_header.h:68
Generic exception thrown by HttpMessage class.
Base class for HttpRequest and HttpResponse.
Generic exception thrown by HttpRequest class.
Definition request.h:21
HttpRequestError(const char *file, size_t line, const char *what)
Definition request.h:23
Represents HTTP request message.
Definition request.h:57
static bool recordIssuer_
Record issuer name.
Definition request.h:255
std::string custom_
Custom name.
Definition request.h:306
Method methodFromString(std::string method) const
Converts HTTP method specified in textual format to Method.
Definition request.cc:236
Method
HTTP methods.
Definition request.h:61
HttpRequestContextPtr context_
Pointer to the HttpRequestContext holding parsed data.
Definition request.h:288
std::string toBriefString() const
Returns HTTP method, URI and HTTP version as a string.
Definition request.cc:169
std::string basic_auth_
Basic auth.
Definition request.h:303
virtual void finalize()
Completes creation of the HTTP request.
Definition request.cc:132
static bool recordSubject_
Access control parameters: Flags which indicate what information to record.
Definition request.h:252
Method getMethod() const
Returns HTTP method of the request.
Definition request.cc:151
std::string getSubject() const
Returns recorded subject name.
Definition request.h:195
virtual void create()
Commits information held in the context into the request.
Definition request.cc:68
std::string getBasicAuth() const
Returns recorded basic auth.
Definition request.h:223
std::string getBody() const
Returns HTTP message body as string.
Definition request.cc:163
bool isPersistent() const
Checks if the client has requested persistent connection.
Definition request.cc:214
void requireHttpMethod(const HttpRequest::Method &method)
Specifies an HTTP method allowed for the request.
Definition request.cc:63
std::string getCustom() const
Returns recorded custom name.
Definition request.h:237
void setTls(bool tls)
Set (record) TLS usage.
Definition request.h:188
static bool recordBasicAuth_
Record basic auth.
Definition request.h:258
HttpRequest()
Constructor for inbound HTTP request.
Definition request.cc:30
bool tls_
TLS usage.
Definition request.h:294
std::string getUri() const
Returns HTTP request URI.
Definition request.cc:157
std::set< Method > required_methods_
Set of required HTTP methods.
Definition request.h:281
const HttpRequestContextPtr & context() const
Returns pointer to the HttpRequestContext.
Definition request.h:98
std::string getRemote() const
Returns remote address.
Definition request.h:106
void setCustom(const std::string &custom)
Set (record) custom name.
Definition request.h:244
std::string methodToString(const HttpRequest::Method &method) const
Converts HTTP method to string.
Definition request.cc:258
std::string getIssuer() const
Returns recorded issuer name.
Definition request.h:209
std::string issuer_
Issuer name.
Definition request.h:300
void setSubject(const std::string &subject)
Set (record) subject name.
Definition request.h:202
void setRemote(const std::string &remote)
Set remote address.
Definition request.h:113
std::string remote_
Remote address.
Definition request.h:291
std::string subject_
Subject name.
Definition request.h:297
Method method_
HTTP method of the request.
Definition request.h:284
virtual void reset()
Reset the state of the object.
Definition request.cc:143
void setBasicAuth(const std::string &basic_auth)
Set (record) basic auth.
Definition request.h:230
virtual std::string toString() const
Returns HTTP message as string.
Definition request.cc:179
bool getTls() const
Access control parameters: get/set methods.
Definition request.h:181
void setIssuer(const std::string &issuer)
Set (record) issuer name.
Definition request.h:216
boost::shared_ptr< BasicHttpAuth > BasicHttpAuthPtr
Type of pointers to basic HTTP authentication objects.
Definition basic_auth.h:70
boost::shared_ptr< HttpRequestContext > HttpRequestContextPtr
Pointer to the HttpRequestContext.
boost::shared_ptr< HttpRequest > HttpRequestPtr
Pointer to the HttpRequest object.
Definition request.h:30
Defines the logger used by the top-level component of kea-lfc.
HTTP protocol version.
Definition http_types.h:14