Lazy RSS
http.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 #include <iostream>
5 
6 #define POCO_WIN32_UTF8
7 #include "Poco/Exception.h"
8 #include "Poco/URI.h"
9 #include "Poco/Net/HTTPRequest.h"
10 #include "Poco/Net/HTTPResponse.h"
11 #include "Poco/Net/HTTPSClientSession.h"
12 #include "Poco/StreamCopier.h"
13 #include "Poco/SharedPtr.h"
14 #include "Poco/Net/SSLManager.h"
15 #include "Poco/Net/KeyConsoleHandler.h"
16 #include "Poco/Net/ConsoleCertificateHandler.h"
17 #include "Poco/Net/AcceptCertificateHandler.h"
18 #include "Poco/Net/RejectCertificateHandler.h"
19 
23 namespace http {
24 
30 enum class METHOD {
31  GET,
32  HEAD,
33  PUT,
34  POST,
35  OPT,
36  DEL,
37  TRACE,
38  CONNECT,
39 };
40 
45  public:
53  HTTP_Response(int status, const std::string &reason, std::string &body) noexcept(true);
54 
58  int status() const;
59 
63  const std::string& reason() const;
64 
68  const std::string& body() const;
69 
76  operator bool() const;
77 
81  operator !() const;
82 
88  explicit operator std::string() const;
89 
90  private:
91  int _status;
92  std::string _reason;
93  std::string _body;
94 };
95 
96 class HTTP_Request {
97  public:
105  explicit HTTP_Request(const char* url);
106 
112  HTTP_Request& set_method(METHOD method);
113 
117  HTTP_Response run();
118 
119  protected:
120  Poco::URI uri;
122 
126  const std::string& method_str() const;
127 };
128 
133  public:
141  explicit HTTPS_Request(const char* url);
142 
146  ~HTTPS_Request();
147 
153  HTTPS_Request& set_method(METHOD method);
154 
160  HTTPS_Request& set_strict_ssl();
161 
169  HTTPS_Request& set_relaxed_ssl();
170 
174  HTTP_Response run();
175 
176  protected:
177  std::function<void()> ssl_init;
178 };
179 }
HTTP OPTIONS Method.
HTTP PUT Method.
Represents HTTP(s) response.
Definition: http.hpp:44
METHOD
HTTP Method enum.
Definition: http.hpp:30
HTTP TRACE Method.
Poco::URI uri
Definition: http.hpp:120
HTTP facilities.
Definition: http.hpp:23
HTTP DELETE Method.
HTTP POST Method.
HTTP GET Method.
std::function< void()> ssl_init
Definition: http.hpp:177
HTTP CONNECT Method.
METHOD method
Definition: http.hpp:121
HTTP HEAD Method.
HTTPS request.
Definition: http.hpp:132
Definition: http.hpp:96