curl_resource.h
Go to the documentation of this file.
1 // Copyright 2022 Fraunhofer IPA
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <sstream>
18 #include <curlpp/cURLpp.hpp>
19 #include <curlpp/Easy.hpp>
20 #include <curlpp/Options.hpp>
21 #include <json/json.h>
22 
25 
27 {
28 public:
29  CurlResource(const std::string& host);
30 
31  void append_path(const std::string& path);
32 
33  void append_query(const std::initializer_list<param_type>& list, bool do_encoding = false);
34 
35  void append_query(const param_map_type& params, bool do_encoding = false);
36 
37  void get(Json::Value& json_resp);
38 
39  void print();
40 
41 private:
42  std::string url_;
43  curlpp::Cleanup cleaner;
44  curlpp::Easy request_;
45  std::list<std::string> header_;
46  std::stringstream response_;
47 };
curlpp::Easy request_
Definition: curl_resource.h:44
std::list< std::string > header_
Definition: curl_resource.h:45
path
CurlResource(const std::string &host)
std::map< std::string, std::string > param_map_type
std::stringstream response_
Definition: curl_resource.h:46
std::string url_
Definition: curl_resource.h:42
curlpp::Cleanup cleaner
Definition: curl_resource.h:43
void append_path(const std::string &path)
void append_query(const std::initializer_list< param_type > &list, bool do_encoding=false)


pf_driver
Author(s): Harsh Deshpande
autogenerated on Fri Feb 24 2023 03:59:35