Kea
2.3.5-git
response_json.h
Go to the documentation of this file.
1
// Copyright (C) 2016-2018 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_RESPONSE_JSON_H
8
#define HTTP_RESPONSE_JSON_H
9
10
#include <
cc/data.h
>
11
#include <
exceptions/exceptions.h
>
12
#include <
http/response.h
>
13
14
namespace
isc
{
15
namespace
http {
16
18
class
HttpResponseJsonError
:
public
HttpResponseError
{
19
public
:
20
HttpResponseJsonError
(
const
char
* file,
size_t
line,
const
char
*
what
) :
21
HttpResponseError
(file, line, what) { };
22
};
23
24
class
HttpResponseJson
;
25
27
typedef
boost::shared_ptr<HttpResponseJson>
HttpResponseJsonPtr
;
28
34
class
HttpResponseJson
:
public
HttpResponse
{
35
public
:
36
38
explicit
HttpResponseJson
();
39
49
explicit
HttpResponseJson
(
const
HttpVersion
&
version
,
50
const
HttpStatusCode
& status_code,
51
const
CallSetGenericBody
& generic_body =
52
CallSetGenericBody::yes
());
53
60
virtual
void
finalize();
61
63
virtual
void
reset();
64
69
data::ConstElementPtr
getBodyAsJson()
const
;
70
75
void
setBodyAsJson(
const
data::ConstElementPtr
& json_body);
76
86
data::ConstElementPtr
getJsonElement(
const
std::string& element_name)
const
;
87
88
private
:
89
99
void
setGenericBody(
const
HttpStatusCode
& status_code);
100
101
protected
:
102
105
void
parseBodyAsJson();
106
108
data::ConstElementPtr
json_
;
109
};
110
111
}
// end of namespace isc::http
112
}
// end of namespace isc
113
114
#endif
isc::http::HttpResponseJsonPtr
boost::shared_ptr< HttpResponseJson > HttpResponseJsonPtr
Pointer to the HttpResponseJson object.
Definition:
response_json.h:24
data.h
exceptions.h
isc::http::HttpVersion
HTTP protocol version.
Definition:
http_types.h:14
isc::http::HttpResponseJson::json_
data::ConstElementPtr json_
Pointer to the parsed JSON body.
Definition:
response_json.h:108
response.h
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::HttpResponseJsonError::HttpResponseJsonError
HttpResponseJsonError(const char *file, size_t line, const char *what)
Definition:
response_json.h:20
isc::http::HttpResponse
Represents HTTP response message.
Definition:
response.h:98
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition:
data.h:27
version
int version()
returns Kea hooks version.
Definition:
bootp/version.cc:13
isc::http::CallSetGenericBody::yes
static const CallSetGenericBody & yes()
Returns encapsulated true.
Definition:
response.h:63
isc::http::HttpResponseError
Generic exception thrown by HttpResponse class.
Definition:
response.h:23
isc::http::HttpResponseJson
Represents HTTP response with JSON content.
Definition:
response_json.h:34
isc
Defines the logger used by the top-level component of kea-lfc.
Definition:
agent_parser.cc:143
isc::http::HttpResponseJsonError
Exception thrown when body of the HTTP message is not JSON.
Definition:
response_json.h:18
isc::http::CallSetGenericBody
Encapsulates the boolean value indicating if the HttpResponse constructor should call its setGenericB...
Definition:
response.h:52
isc::http::HttpStatusCode
HttpStatusCode
HTTP status codes (cf RFC 2068)
Definition:
response.h:30
src
lib
http
response_json.h
Generated on Mon Jan 30 2023 14:16:15 for Kea by
1.8.13