10#include <boost/algorithm/string.hpp>
11#include <boost/lexical_cast.hpp>
17const std::string crlf =
"\r\n";
32 method_(
Method::HTTP_METHOD_UNKNOWN),
34 remote_(
""), tls_(false), subject_(
""), issuer_(
""),
35 basic_auth_(
""), custom_(
"") {
39 const std::string& uri,
44 method_(
Method::HTTP_METHOD_UNKNOWN),
46 remote_(
""), tls_(false), subject_(
""), issuer_(
""),
47 basic_auth_(
""), custom_(
"") {
56 host_header.getValue()));
93 for (
auto const& header :
context_->headers_) {
95 headers_[hdr->getLowerCaseName()] = hdr;
100 boost::lexical_cast<std::string>(
context_->body_.length())));
107 auto header =
headers_.find(req_header.first);
110 <<
" not found in the HTTP request");
111 }
else if (!req_header.second->getValue().empty() &&
112 !header->second->isValueEqual(req_header.second->getValue())) {
116 <<
" value is " << req_header.second->getValue()
117 <<
", but " << header->second->getValue() <<
" was found");
121 }
catch (
const std::exception& ex) {
172 std::ostringstream s;
182 std::ostringstream s;
191 s << host_header->getName() <<
": " << host_header->getValue() << crlf;
199 for (
auto const& header_it :
headers_) {
200 if (header_it.second->getName() !=
"Host") {
201 s << header_it.second->getName() <<
": " << header_it.second->getValue()
224 std::string conn_value;
226 conn_value = conn->getLowerCaseValue();
237 boost::to_upper(method);
238 if (method ==
"GET") {
240 }
else if (method ==
"POST") {
242 }
else if (method ==
"HEAD") {
244 }
else if (method ==
"PUT") {
246 }
else if (method ==
"DELETE") {
248 }
else if (method ==
"OPTIONS") {
250 }
else if (method ==
"CONNECT") {
275 return (
"unknown HTTP method");
int version()
returns Kea hooks version.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Base class for HttpRequest and HttpResponse.
HttpHeaderMap headers_
Parsed HTTP headers.
HttpVersion http_version_
HTTP version numbers.
HttpVersion getHttpVersion() const
Returns HTTP version number (major and minor).
void checkFinalized() const
Checks if the finalize was called.
void checkCreated() const
Checks if the create was called.
bool created_
Flag indicating whether create was called.
std::set< HttpVersion > required_versions_
Set of required HTTP versions.
Direction getDirection() const
Returns HTTP message direction.
bool inRequiredSet(const T &element, const std::set< T > &element_set) const
Checks if the set is empty or the specified element belongs to this set.
HttpHeaderPtr getHeader(const std::string &header_name) const
Returns object encapsulating HTTP header.
bool finalized_
Flag indicating whether finalize was called.
HttpHeaderMap required_headers_
Map holding required HTTP headers.
Generic exception thrown by HttpRequest class.
static bool recordIssuer_
Record issuer name.
Method methodFromString(std::string method) const
Converts HTTP method specified in textual format to Method.
HttpRequestContextPtr context_
Pointer to the HttpRequestContext holding parsed data.
std::string toBriefString() const
Returns HTTP method, URI and HTTP version as a string.
virtual void finalize()
Completes creation of the HTTP request.
static bool recordSubject_
Access control parameters: Flags which indicate what information to record.
Method getMethod() const
Returns HTTP method of the request.
virtual void create()
Commits information held in the context into the request.
std::string getBody() const
Returns HTTP message body as string.
bool isPersistent() const
Checks if the client has requested persistent connection.
void requireHttpMethod(const HttpRequest::Method &method)
Specifies an HTTP method allowed for the request.
static bool recordBasicAuth_
Record basic auth.
HttpRequest()
Constructor for inbound HTTP request.
std::string getUri() const
Returns HTTP request URI.
std::set< Method > required_methods_
Set of required HTTP methods.
const HttpRequestContextPtr & context() const
Returns pointer to the HttpRequestContext.
std::string methodToString(const HttpRequest::Method &method) const
Converts HTTP method to string.
Method method_
HTTP method of the request.
virtual void reset()
Reset the state of the object.
virtual std::string toString() const
Returns HTTP message as string.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< BasicHttpAuth > BasicHttpAuthPtr
Type of pointers to basic HTTP authentication objects.
boost::shared_ptr< HttpHeader > HttpHeaderPtr
Pointer to the HttpHeader class.
Defines the logger used by the top-level component of kea-lfc.
unsigned minor_
Minor HTTP version.
static const HttpVersion & HTTP_10()
HTTP version 1.0.
unsigned major_
Major HTTP version.