ScummVM API documentation
curlrequest.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BACKENDS_NETWORKING_CURL_CURLREQUEST_H
23 #define BACKENDS_NETWORKING_CURL_CURLREQUEST_H
24 
25 #include "backends/networking/curl/request.h"
26 #include "common/path.h"
27 #include "common/str.h"
28 #include "common/array.h"
29 #include "common/hashmap.h"
30 #include "common/hash-str.h"
31 
32 struct curl_slist;
33 
34 namespace Networking {
35 
36 class NetworkReadStream;
37 
38 typedef Response<NetworkReadStream *> NetworkReadStreamResponse;
39 typedef Common::BaseCallback<const NetworkReadStreamResponse &> *NetworkReadStreamCallback;
40 
41 class CurlRequest: public Request {
42 protected:
43  Common::String _url;
44  NetworkReadStream *_stream;
45  curl_slist *_headersList;
46  Common::String _postFields;
49  byte *_bytesBuffer;
50  uint32 _bytesBufferSize;
51  bool _uploading; //using PUT method
52  bool _usingPatch; //using PATCH method
53  bool _keepAlive;
54  long _keepAliveIdle, _keepAliveInterval;
55 
56  NetworkReadStream *makeStream();
57 
58 public:
60  ~CurlRequest() override;
61 
62  void handle() override;
63  void restart() override;
64  Common::String date() const override;
65 
67  virtual void setHeaders(const Common::Array<Common::String> &headers);
68 
70  virtual void addHeader(const Common::String &header);
71 
73  virtual void addPostField(const Common::String &field);
74 
76  virtual void addFormField(const Common::String &name, const Common::String &value);
77 
79  virtual void addFormFile(const Common::String &name, const Common::Path &filename);
80 
82  virtual void setBuffer(byte *buffer, uint32 size);
83 
85  virtual void usePut();
86 
88  virtual void usePatch();
89 
91  virtual void connectionKeepAlive(long idle = 120, long interval = 60);
92  virtual void connectionClose();
93 
98  virtual NetworkReadStreamResponse execute();
99 
102 
104  void wait(int spinlockDelay = 5);
105 };
106 
107 } // End of namespace Networking
108 
109 #endif
Definition: str.h:59
virtual void addPostField(const Common::String &field)
void handle() override
virtual NetworkReadStreamResponse execute()
virtual void connectionKeepAlive(long idle=120, long interval=60)
virtual void usePut()
Definition: scummvmcloud.h:31
virtual void addHeader(const Common::String &header)
Definition: path.h:52
const NetworkReadStream * getNetworkReadStream() const
virtual void setBuffer(byte *buffer, uint32 size)
void wait(int spinlockDelay=5)
virtual void setHeaders(const Common::Array< Common::String > &headers)
virtual void usePatch()
virtual void addFormField(const Common::String &name, const Common::String &value)
void restart() override
Common::String date() const override
Definition: networkreadstream.h:37
virtual void addFormFile(const Common::String &name, const Common::Path &filename)
Definition: curlrequest.h:41
Definition: request.h:119