Kea  2.1.7-git
request.h
Go to the documentation of this file.
1 // Copyright (C) 2016-2022 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>
13 #include <http/request_context.h>
14 #include <boost/shared_ptr.hpp>
15 #include <cstdint>
16 
17 namespace isc {
18 namespace http {
19 
22 public:
23  HttpRequestError(const char* file, size_t line, const char* what) :
24  HttpMessageError(file, line, what) { };
25 };
26 
28 
30 typedef boost::shared_ptr<HttpRequest> HttpRequestPtr;
31 
58 public:
59 
61  enum class Method {
62  HTTP_GET,
63  HTTP_POST,
64  HTTP_HEAD,
65  HTTP_PUT,
66  HTTP_DELETE,
67  HTTP_OPTIONS,
68  HTTP_CONNECT,
69  HTTP_METHOD_UNKNOWN
70  };
71 
73  HttpRequest();
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 
98  const HttpRequestContextPtr& context() const {
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 
260 protected:
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
Represents HTTP Host header.
Definition: http_header.h:68
std::string remote_
Remote address.
Definition: request.h:291
std::string getCustom() const
Returns recorded custom name.
Definition: request.h:237
bool getTls() const
Access control parameters: get/set methods.
Definition: request.h:181
Generic exception thrown by HttpRequest class.
Definition: request.h:21
std::string getSubject() const
Returns recorded subject name.
Definition: request.h:195
Method method_
HTTP method of the request.
Definition: request.h:284
Generic exception thrown by HttpMessage class.
Definition: http_message.h:22
void setIssuer(const std::string &issuer)
Set (record) issuer name.
Definition: request.h:216
bool tls_
TLS usage.
Definition: request.h:294
HTTP protocol version.
Definition: http_types.h:14
std::string issuer_
Issuer name.
Definition: request.h:300
HttpRequestContextPtr context_
Pointer to the HttpRequestContext holding parsed data.
Definition: request.h:288
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
const HttpRequestContextPtr & context() const
Returns pointer to the HttpRequestContext.
Definition: request.h:98
Base class for HttpRequest and HttpResponse.
Definition: http_message.h:62
boost::shared_ptr< HttpRequestContext > HttpRequestContextPtr
Pointer to the HttpRequestContext.
std::string getIssuer() const
Returns recorded issuer name.
Definition: request.h:209
Base class for classes which need to be associated with a CalloutHandle object.
std::string subject_
Subject name.
Definition: request.h:297
static bool recordSubject_
Access control parameters: Flags which indicate what information to record.
Definition: request.h:252
int version()
returns Kea hooks version.
static bool recordIssuer_
Record issuer name.
Definition: request.h:255
Method
HTTP methods.
Definition: request.h:61
void setTls(bool tls)
Set (record) TLS usage.
Definition: request.h:188
std::string custom_
Custom name.
Definition: request.h:306
void setRemote(const std::string &remote)
Set remote address.
Definition: request.h:113
Defines the logger used by the top-level component of kea-lfc.
void setCustom(const std::string &custom)
Set (record) custom name.
Definition: request.h:244
std::string getBasicAuth() const
Returns recorded basic auth.
Definition: request.h:223
static bool recordBasicAuth_
Record basic auth.
Definition: request.h:258
void setBasicAuth(const std::string &basic_auth)
Set (record) basic auth.
Definition: request.h:230
boost::shared_ptr< BasicHttpAuth > BasicHttpAuthPtr
Type of pointers to basic HTTP authentication objects.
Definition: basic_auth.h:70
Represents HTTP request message.
Definition: request.h:57
boost::shared_ptr< HttpRequest > HttpRequestPtr
Pointer to the HttpRequest object.
Definition: request.h:27
std::set< Method > required_methods_
Set of required HTTP methods.
Definition: request.h:281
std::string basic_auth_
Basic auth.
Definition: request.h:303
HttpRequestError(const char *file, size_t line, const char *what)
Definition: request.h:23
std::string getRemote() const
Returns remote address.
Definition: request.h:106
void setSubject(const std::string &subject)
Set (record) subject name.
Definition: request.h:202