ScummVM API documentation
httprequest.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_HTTP_HTTPREQUEST_H
23 #define BACKENDS_NETWORKING_HTTP_HTTPREQUEST_H
24 
25 #include "backends/networking/http/request.h"
26 #include "common/path.h"
27 #include "common/str.h"
28 #include "common/array.h"
29 #include "common/list.h"
30 #include "common/hashmap.h"
31 #include "common/hash-str.h"
32 
33 namespace Networking {
34 
35 typedef Common::Array<Common::String> RequestHeaders;
36 
37 class NetworkReadStream;
38 
39 typedef Response<NetworkReadStream *> NetworkReadStreamResponse;
40 typedef Common::BaseCallback<const NetworkReadStreamResponse &> *NetworkReadStreamCallback;
41 
42 class HttpRequest: public Request {
43 protected:
44  Common::String _url;
45  NetworkReadStream *_stream;
46  RequestHeaders _headersList;
47  Common::String _postFields;
50  byte *_bytesBuffer;
51  uint32 _bytesBufferSize;
52  bool _uploading; //using PUT method
53  bool _usingPatch; //using PATCH method
54  bool _keepAlive;
55  long _keepAliveIdle, _keepAliveInterval;
56 
57  NetworkReadStream *makeStream();
58 
59 public:
61  ~HttpRequest() override;
62 
63  void handle() override;
64  void restart() override;
65  Common::String date() const override;
66 
68  virtual void setHeaders(const Common::Array<Common::String> &headers);
69 
71  virtual void addHeader(const Common::String &header);
72 
74  virtual void addPostField(const Common::String &field);
75 
77  virtual void addFormField(const Common::String &name, const Common::String &value);
78 
80  virtual void addFormFile(const Common::String &name, const Common::Path &filename);
81 
83  virtual void setBuffer(byte *buffer, uint32 size);
84 
86  virtual void usePut();
87 
89  virtual void usePatch();
90 
92  virtual void connectionKeepAlive(long idle = 120, long interval = 60);
93  virtual void connectionClose();
94 
99  virtual NetworkReadStreamResponse execute();
100 
103 
105  void wait(int spinlockDelay = 5);
106 };
107 
108 } // End of namespace Networking
109 
110 #endif
virtual void usePatch()
virtual void addPostField(const Common::String &field)
Definition: str.h:59
virtual void addFormField(const Common::String &name, const Common::String &value)
Definition: scummvmcloud.h:32
void handle() override
virtual NetworkReadStreamResponse execute()
virtual void setBuffer(byte *buffer, uint32 size)
Definition: path.h:52
virtual void addFormFile(const Common::String &name, const Common::Path &filename)
Definition: httprequest.h:42
Common::String date() const override
void wait(int spinlockDelay=5)
const NetworkReadStream * getNetworkReadStream() const
Definition: networkreadstream.h:37
virtual void connectionKeepAlive(long idle=120, long interval=60)
virtual void addHeader(const Common::String &header)
virtual void usePut()
virtual void setHeaders(const Common::Array< Common::String > &headers)
void restart() override
Definition: request.h:119