10 #include <boost/algorithm/string.hpp>
11 #include <boost/lexical_cast.hpp>
17 const std::string crlf =
"\r\n";
26 method_(
Method::HTTP_METHOD_UNKNOWN),
31 const std::string& uri,
36 method_(
Method::HTTP_METHOD_UNKNOWN),
83 for (
auto header =
context_->headers_.begin();
87 headers_[hdr->getLowerCaseName()] = hdr;
92 boost::lexical_cast<std::string>(
context_->body_.length())));
101 auto header =
headers_.find(req_header->first);
104 <<
" not found in the HTTP request");
105 }
else if (!req_header->second->getValue().empty() &&
106 !header->second->isValueEqual(req_header->second->getValue())) {
110 <<
" value is " << req_header->second->getValue()
111 <<
", but " << header->second->getValue() <<
" was found");
115 }
catch (
const std::exception& ex) {
166 std::ostringstream s;
176 std::ostringstream s;
185 s << host_header->getName() <<
": " << host_header->getValue() << crlf;
195 if (header_it->second->getName() !=
"Host") {
196 s << header_it->second->getName() <<
": " << header_it->second->getValue()
219 std::string conn_value;
221 conn_value = conn->getLowerCaseValue();
232 boost::to_upper(method);
233 if (method ==
"GET") {
235 }
else if (method ==
"POST") {
237 }
else if (method ==
"HEAD") {
239 }
else if (method ==
"PUT") {
241 }
else if (method ==
"DELETE") {
243 }
else if (method ==
"OPTIONS") {
245 }
else if (method ==
"CONNECT") {
270 return (
"unknown HTTP method");
void requireHttpMethod(const HttpRequest::Method &method)
Specifies an HTTP method allowed for the request.
bool isPersistent() const
Checks if the client has requested persistent connection.
boost::shared_ptr< HttpHeader > HttpHeaderPtr
Pointer to the HttpHeader class.
Generic exception thrown by HttpRequest class.
Method method_
HTTP method of the request.
Direction getDirection() const
Returns HTTP message direction.
bool finalized_
Flag indicating whether finalize was called.
virtual std::string toString() const
Returns HTTP message as string.
HttpRequestContextPtr context_
Pointer to the HttpRequestContext holding parsed data.
unsigned major_
Major HTTP version.
HttpHeaderPtr getHeader(const std::string &header_name) const
Returns object encapsulating HTTP header.
Method methodFromString(std::string method) const
Converts HTTP method specified in textual format to Method.
std::string methodToString(const HttpRequest::Method &method) const
Converts HTTP method to string.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
std::string getBody() const
Returns HTTP message body as string.
bool created_
Flag indicating whether create was called.
HttpHeaderMap required_headers_
Map holding required HTTP headers.
Base class for HttpRequest and HttpResponse.
std::string getUri() const
Returns HTTP request URI.
HttpRequest()
Constructor for inbound HTTP request.
std::string toBriefString() const
Returns HTTP method, URI and HTTP version as a string.
HttpVersion getHttpVersion() const
Returns HTTP version number (major and minor).
int version()
returns Kea hooks version.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void checkFinalized() const
Checks if the finalize was called.
const HttpRequestContextPtr & context() const
Returns pointer to the HttpRequestContext.
HttpVersion http_version_
HTTP version numbers.
virtual void create()
Commits information held in the context into the request.
std::set< HttpVersion > required_versions_
Set of required HTTP versions.
static const HttpVersion & HTTP_10()
HTTP version 1.0.
boost::shared_ptr< BasicHttpAuth > BasicHttpAuthPtr
Type of pointers to basic HTTP authentication objects.
virtual void finalize()
Completes creation of the HTTP request.
void checkCreated() const
Checks if the create was called.
HttpHeaderMap headers_
Parsed HTTP headers.
std::set< Method > required_methods_
Set of required HTTP methods.
Method getMethod() const
Returns HTTP method of the request.
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.
unsigned minor_
Minor HTTP version.
virtual void reset()
Reset the state of the object.