| Kea 3.0.2-git

post_request_json.h
Go to the documentation of this file.
1// Copyright (C) 2016-2024 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_POST_REQUEST_JSON_H
8#define HTTP_POST_REQUEST_JSON_H
9
10#include <cc/data.h>
11#include <exceptions/exceptions.h>
12#include <http/post_request.h>
13#include <boost/shared_ptr.hpp>
14#include <string>
15
16 namespace isc {
17 namespace http {
18
20 class HttpRequestJsonError : public HttpRequestError {
21 public:
22 HttpRequestJsonError(const char* file, size_t line, const char* what) :
23 HttpRequestError(file, line, what) { }
24};
25
26 class PostHttpRequestJson;
27
29 typedef boost::shared_ptr<PostHttpRequestJson> PostHttpRequestJsonPtr;
30
37 class PostHttpRequestJson : public PostHttpRequest {
38 public:
39
41 explicit PostHttpRequestJson();
42
55 explicit PostHttpRequestJson(const Method& method, const std::string& uri,
56 const HttpVersion& version,
57 const HostHttpHeader& host_header = HostHttpHeader(),
58 const BasicHttpAuthPtr& basic_auth = BasicHttpAuthPtr());
59
64 virtual void finalize();
65
67 virtual void reset();
68
73 data::ConstElementPtr getBodyAsJson() const;
74
83 void setBodyAsJson(const data::ConstElementPtr& body);
84
94 data::ConstElementPtr getJsonElement(const std::string& element_name) const;
95
96 protected:
97
100 void parseBodyAsJson();
101
103 data::ConstElementPtr json_;
104
105};
106
107} // namespace http
108} // namespace isc
109
110#endif
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::http::HostHttpHeader
Represents HTTP Host header.
Definition http_header.h:68
isc::http::HttpRequestError::HttpRequestError
HttpRequestError(const char *file, size_t line, const char *what)
Definition request.h:23
isc::http::HttpRequestJsonError::HttpRequestJsonError
HttpRequestJsonError(const char *file, size_t line, const char *what)
Definition post_request_json.h:22
isc::http::HttpRequest::Method
Method
HTTP methods.
Definition request.h:61
isc::http::PostHttpRequestJson::finalize
virtual void finalize()
Complete parsing of the HTTP request.
Definition post_request_json.cc:32
isc::http::PostHttpRequestJson::getJsonElement
data::ConstElementPtr getJsonElement(const std::string &element_name) const
Retrieves a single JSON element.
Definition post_request_json.cc:66
isc::http::PostHttpRequestJson::setBodyAsJson
void setBodyAsJson(const data::ConstElementPtr &body)
Sets JSON body for an outbound message.
Definition post_request_json.cc:55
isc::http::PostHttpRequestJson::PostHttpRequestJson
PostHttpRequestJson()
Constructor for inbound HTTP request.
Definition post_request_json.cc:16
isc::http::PostHttpRequestJson::getBodyAsJson
data::ConstElementPtr getBodyAsJson() const
Retrieves JSON body.
Definition post_request_json.cc:49
isc::http::PostHttpRequestJson::reset
virtual void reset()
Reset the state of the object.
Definition post_request_json.cc:43
isc::http::PostHttpRequestJson::json_
data::ConstElementPtr json_
Pointer to the parsed JSON body.
Definition post_request_json.h:103
isc::http::PostHttpRequestJson::parseBodyAsJson
void parseBodyAsJson()
Interprets body as JSON, which can be later retrieved using data element objects.
Definition post_request_json.cc:85
isc::http::PostHttpRequest::PostHttpRequest
PostHttpRequest()
Constructor for inbound HTTP request.
Definition post_request.cc:14
version
int version()
returns Kea hooks version.
Definition d2/gss_tsig/version.cc:13
data.h
exceptions.h
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::http
Definition auth_config.h:19
isc::http::BasicHttpAuthPtr
boost::shared_ptr< BasicHttpAuth > BasicHttpAuthPtr
Type of pointers to basic HTTP authentication objects.
Definition basic_auth.h:70
isc::http::PostHttpRequestJsonPtr
boost::shared_ptr< PostHttpRequestJson > PostHttpRequestJsonPtr
Pointer to PostHttpRequestJson.
Definition post_request_json.h:29
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
post_request.h
isc::http::HttpVersion
HTTP protocol version.
Definition http_types.h:14