10#include <boost/algorithm/string.hpp>
11#include <boost/lexical_cast.hpp>
17const std::string crlf =
"\r\n";
26 method_(
Method::HTTP_METHOD_UNKNOWN),
33 method_(
Method::HTTP_METHOD_UNKNOWN),
72 for (
auto header =
context_->headers_.begin();
76 headers_[hdr->getLowerCaseName()] = hdr;
81 boost::lexical_cast<std::string>(
context_->body_.length())));
90 auto header =
headers_.find(req_header->first);
93 <<
" not found in the HTTP request");
94 }
else if (!req_header->second->getValue().empty() &&
95 !header->second->isValueEqual(req_header->second->getValue())) {
99 <<
" value is " << req_header->second->getValue()
100 <<
", but " << header->second->getValue() <<
" was found");
104 }
catch (
const std::exception& ex) {
155 std::ostringstream s;
165 std::ostringstream s;
171 s << header_it->second->getName() <<
": " << header_it->second->getValue()
193 std::string conn_value;
195 conn_value = conn->getLowerCaseValue();
206 boost::to_upper(method);
207 if (method ==
"GET") {
209 }
else if (method ==
"POST") {
211 }
else if (method ==
"HEAD") {
213 }
else if (method ==
"PUT") {
215 }
else if (method ==
"DELETE") {
217 }
else if (method ==
"OPTIONS") {
219 }
else if (method ==
"CONNECT") {
244 return (
"unknown HTTP method");
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.
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.
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.
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.
int version()
returns Kea hooks version.
boost::shared_ptr< HttpHeader > HttpHeaderPtr
Pointer to the HttpHeader class.
Defines the logger used by the top-level component of kea-dhcp-ddns.
unsigned minor_
Minor HTTP version.
static const HttpVersion & HTTP_10()
HTTP version 1.0.
unsigned major_
Major HTTP version.