Operator
C++ library for plugging into matrix.org
http.hh
Go to the documentation of this file.
1 
20 #ifndef __OPERATOR_QT_HTTP_HH_
21 #define __OPERATOR_QT_HTTP_HH_
22 
23 #include <QtNetwork>
24 
26 #include <liboperator/error.hh>
27 
28 #include <memory>
29 
30 namespace Operator {
33  namespace Qt {
34  class HTTPAdapter : public HTTP::Adapter {
35  public:
36  HTTPAdapter(QNetworkAccessManager *);
37  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 &);
38  private:
39  QNetworkAccessManager *manager;
40  };
41 
42  class NetworkError : public Error::Error {
43  public:
44  NetworkError(QNetworkReply::NetworkError _err, std::string _msg)
45  : err(_err),
46  msg(_msg)
47  {}
48  std::string to_string() const { return msg; };
49  QNetworkReply::NetworkError getQtError() const { return err; }
50  private:
51  QNetworkReply::NetworkError err;
52  std::string msg;
53  };
54  }
55 }
56 
57 #endif // __OPERATOR_QT_HTTP_HH_
Definition: client.hh:32
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
Definition: http.hh:42
Definition: http.hh:34