TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tb_http_request.hpp
1 
9 #ifndef TurtleBrains_HTTPRequest_hpp
10 #define TurtleBrains_HTTPRequest_hpp
11 
12 #include <turtle_brains/core/tb_configuration.hpp>
13 #if defined(tb_with_networking)
14 
15 #include <turtle_brains/core/tb_types.hpp>
16 #include <turtle_brains/core/tb_noncopyable.hpp>
17 
18 #include <turtle_brains/network/tb_http_response.hpp>
19 
20 #include <memory>
21 #include <functional>
22 
23 namespace tbImplementation
24 {
25  class RequestImplementation;
26 };
27 
28 namespace TurtleBrains
29 {
30  namespace Network
31  {
32  namespace HTTP
33  {
34  enum class Method { Get, Post };
35 
36  class Request : public tbCore::Noncopyable
37  {
38  public:
45  explicit Request(const tbCore::tbString& remotePath, const Method httpMethod = Method::Get);
46 
50  ~Request(void);
51 
59  void AddParameter(const tbCore::tbString& name, const tbCore::tbString& value);
60 
64  void AddHeader(const tbCore::tbString& headerLine);
65 
70  void AddFileContents(const tbCore::tbString& filepath, bool isBinary);
71 
76  void AddFileContents(const char* fileData, size_t fileSize);
77 
82  void AddPostContents(const char* postData, size_t postSize);
83 
88  void SetDebugFlag(void);
89 
94  Response GetResponse(void);
95 
106  void GetResponseAsync(std::function<void(Response)> responseCallback);
107 
108  private:
109  std::unique_ptr<tbImplementation::RequestImplementation> mImplementation;
110  };
111 
112  }; /* namespace HTTP */
113  }; /* namespace Network */
114 }; /* namespace TurtleBrains */
115 
116 namespace tbNetwork = TurtleBrains::Network;
117 
118 #endif /* tb_with_networking */
119 #endif /* TurtleBrains_HTTPRequest_hpp */
Definition: tb_noncopyable.hpp:22
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
std::string tbString
Definition: tb_string.hpp:335
Definition: tb_application_dialog.hpp:19