restclient-cpp
C++ client for making HTTP/REST requests
restclient.h
Go to the documentation of this file.
1 
9 #ifndef INCLUDE_RESTCLIENT_CPP_RESTCLIENT_H_
10 #define INCLUDE_RESTCLIENT_CPP_RESTCLIENT_H_
11 
12 #include <curl/curl.h>
13 #include <string>
14 #include <map>
15 #include <cstdlib>
16 
17 #include "restclient-cpp/version.h"
18 
22 namespace RestClient {
23 
27 typedef std::map<std::string, std::string> HeaderFields;
28 
38 typedef struct {
39  int code;
40  std::string body;
41  HeaderFields headers;
42 } Response;
43 
44 // init and disable functions
45 int init();
46 void disable();
47 
53 Response get(const std::string& url);
54 Response post(const std::string& url,
55  const std::string& content_type,
56  const std::string& data);
57 Response put(const std::string& url,
58  const std::string& content_type,
59  const std::string& data);
60 Response del(const std::string& url);
61 Response head(const std::string& url);
62 
63 } // namespace RestClient
64 
65 #endif // INCLUDE_RESTCLIENT_CPP_RESTCLIENT_H_
HeaderFields headers
Definition: restclient.h:41
int code
Definition: restclient.h:39
This structure represents the HTTP response data.
Definition: restclient.h:38
std::map< std::string, std::string > HeaderFields
Definition: restclient.h:27
void disable()
global disable function. Call this before you terminate your program.
Definition: restclient.cc:37
Response head(const std::string &url)
HTTP HEAD method.
Definition: restclient.cc:118
Response del(const std::string &url)
HTTP DELETE method.
Definition: restclient.cc:103
Response put(const std::string &url, const std::string &content_type, const std::string &data)
HTTP PUT method.
Definition: restclient.cc:85
Response post(const std::string &url, const std::string &content_type, const std::string &data)
HTTP POST method.
Definition: restclient.cc:65
int init()
global init function. Call this before you start any threads.
Definition: restclient.cc:24
std::string body
Definition: restclient.h:40
namespace for all RestClient definitions
Definition: connection.h:23