Kea  2.1.7-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 
19 public:
20  HttpResponseJsonError(const char* file, size_t line, const char* what) :
21  HttpResponseError(file, line, what) { };
22 };
23 
25 
27 typedef boost::shared_ptr<HttpResponseJson> HttpResponseJsonPtr;
28 
35 public:
36 
38  explicit HttpResponseJson();
39 
49  explicit HttpResponseJson(const HttpVersion& version,
50  const HttpStatusCode& status_code,
51  const CallSetGenericBody& generic_body =
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 
109 };
110 
111 } // end of namespace isc::http
112 } // end of namespace isc
113 
114 #endif
boost::shared_ptr< HttpResponseJson > HttpResponseJsonPtr
Pointer to the HttpResponseJson object.
Definition: response_json.h:24
HTTP protocol version.
Definition: http_types.h:14
data::ConstElementPtr json_
Pointer to the parsed JSON body.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
HttpResponseJsonError(const char *file, size_t line, const char *what)
Definition: response_json.h:20
Represents HTTP response message.
Definition: response.h:98
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
int version()
returns Kea hooks version.
static const CallSetGenericBody & yes()
Returns encapsulated true.
Definition: response.h:63
Generic exception thrown by HttpResponse class.
Definition: response.h:23
Represents HTTP response with JSON content.
Definition: response_json.h:34
Defines the logger used by the top-level component of kea-lfc.
Exception thrown when body of the HTTP message is not JSON.
Definition: response_json.h:18
Encapsulates the boolean value indicating if the HttpResponse constructor should call its setGenericB...
Definition: response.h:52
HttpStatusCode
HTTP status codes (cf RFC 2068)
Definition: response.h:30