 |
Kea
1.5.0
|
Go to the documentation of this file.
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),
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");
void checkCreated() const
Checks if the create was called.
void checkFinalized() const
Checks if the finalize was called.
virtual void reset()
Reset the state of the object.
std::set< HttpVersion > required_versions_
Set of required HTTP versions.
int version()
returns Kea hooks version.
Method getMethod() const
Returns HTTP method of the request.
HttpHeaderPtr getHeader(const std::string &header_name) const
Returns object encapsulating HTTP header.
HttpRequestContextPtr context_
Pointer to the HttpRequestContext holding parsed data.
std::set< Method > required_methods_
Set of required HTTP methods.
HttpHeaderMap headers_
Parsed HTTP headers.
Method methodFromString(std::string method) const
Converts HTTP method specified in textual format to Method.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Generic exception thrown by HttpRequest class.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
HttpRequest()
Constructor for inbound HTTP request.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Method method_
HTTP method of the request.
virtual std::string toString() const
Returns HTTP message as string.
unsigned major_
Major HTTP version.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Base class for HttpRequest and HttpResponse.
std::string methodToString(const HttpRequest::Method &method) const
Converts HTTP method to string.
static const HttpVersion & HTTP_10()
HTTP version 1.0.
bool created_
Flag indicating whether create was called.
HttpVersion http_version_
HTTP version numbers.
std::string getBody() const
Returns HTTP message body as string.
boost::shared_ptr< HttpHeader > HttpHeaderPtr
Pointer to the HttpHeader class.
bool isPersistent() const
Checks if the client has requested persistent connection.
Direction getDirection() const
Returns HTTP message direction.
HttpHeaderMap required_headers_
Map holding required HTTP headers.
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.
void requireHttpMethod(const HttpRequest::Method &method)
Specifies an HTTP method allowed for the request.
unsigned minor_
Minor HTTP version.
HttpVersion getHttpVersion() const
Returns HTTP version number (major and minor).
bool finalized_
Flag indicating whether finalize was called.
const HttpRequestContextPtr & context() const
Returns pointer to the HttpRequestContext.
virtual void finalize()
Completes creation of the HTTP request.
virtual void create()
Commits information held in the context into the request.
std::string toBriefString() const
Returns HTTP method, URI and HTTP version as a string.
std::string getUri() const
Returns HTTP request URI.