Operator
C++ library for plugging into matrix.org
http.hh
Go to the documentation of this file.
1 
20 #ifndef __OPERATOR_GLIB_HTTP_HH_
21 #define __OPERATOR_GLIB_HTTP_HH_
22 
23 #include <glib.h>
24 #include <libsoup/soup.h>
25 
27 #include <liboperator/error.hh>
28 
29 #include <memory>
30 
31 namespace Operator {
32  namespace GLib {
33  class HTTPAdapter : public HTTP::Adapter {
34  public:
35  HTTPAdapter(SoupSession *);
36  void httpcall(const std::string &method, const std::string &URL, const HTTP::headers_t &, std::unique_ptr<std::istream> body, size_t timeout, const HTTP::httpcallback_t &);
37  private:
38  SoupSession *session;
39  };
40 
41  // FIXME: move to a separate header file
42  class Error : public Operator::Error::Error {
43  public:
44  Error(GError *_err)
45  : err(_err) {}
46  ~Error() {
47  g_error_free(err);
48  }
49  std::string to_string() const { return err->message; };
50  GError *getGError() const { return err; }
51  private:
52  GError *err;
53  };
54  }
55 }
56 
57 #endif // __OPERATOR_GLIB_HTTP_HH_
Definition: http.hh:42
Definition: client.hh:32
Definition: http.hh:33
HTTP adapter interface.
Definition: http.hh:48
std::vector< header_t > headers_t
list of HTTP headers.
Definition: http.hh:41
client functionality using the HTTP-based API
std::function< void(std::unique_ptr< Error::Error >, short code, const headers_t &, std::unique_ptr< std::istream > body)> httpcallback_t
HTTP callback type.
Definition: http.hh:44
Error handling.
base error class.
Definition: error.hh:37