Operator
C++ library for plugging into matrix.org
All Classes Namespaces Files Functions Typedefs Pages
http.hh
Go to the documentation of this file.
1 
20 #ifndef __OPERATOR_HTTP_HH_
21 #define __OPERATOR_HTTP_HH_
22 
23 #include "error.hh"
24 
25 #include <string>
26 #include <sstream>
27 #include <map>
28 #include <vector>
29 #include <memory>
30 #include <functional>
31 
32 namespace Operator {
35  namespace HTTP {
38  typedef std::pair<std::string, std::string> header_t;
41  typedef std::vector<header_t> headers_t;
44  typedef std::function<void (std::unique_ptr<Error::Error>, short code, const headers_t &, std::unique_ptr<std::istream> body)> httpcallback_t;
45 
48  class Adapter {
49  public:
50  virtual void httpcall(const std::string &method, const std::string &URL, const headers_t &, std::unique_ptr<std::istream> body, size_t timeout, const httpcallback_t &) = 0;
51  };
52 
53  struct url_encode;
54 
55  std::ostream & operator<<(std::ostream &os, const url_encode &ue);
56 
57  struct url_encode {
58  const std::string &orig;
59  url_encode(const std::string &o) : orig(o) {}
60  operator std::string() const {
61  std::ostringstream out;
62  out << (*this);
63  return out.str();
64  }
65  };
66  }
67 }
68 #endif // __OPERATOR_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
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
std::pair< std::string, std::string > header_t
HTTP header.
Definition: http.hh:38
Error handling.
Definition: http.hh:57