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
33namespace Networking {
34
35typedef Common::Array<Common::String> RequestHeaders;
36
37class NetworkReadStream;
38
39typedef Response<NetworkReadStream *> NetworkReadStreamResponse;
40typedef Common::BaseCallback<const NetworkReadStreamResponse &> *NetworkReadStreamCallback;
41
42class HttpRequest: public Request {
43protected:
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
59public:
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
100
103
105 void wait(int spinlockDelay = 5);
106};
107
108} // End of namespace Networking
109
110#endif
Definition: path.h:52
Definition: str.h:59
Definition: httprequest.h:42
virtual void usePatch()
void handle() override
virtual void usePut()
virtual void setHeaders(const Common::Array< Common::String > &headers)
virtual void connectionKeepAlive(long idle=120, long interval=60)
virtual void addPostField(const Common::String &field)
virtual void setBuffer(byte *buffer, uint32 size)
virtual void addFormFile(const Common::String &name, const Common::Path &filename)
Common::String date() const override
virtual void addFormField(const Common::String &name, const Common::String &value)
virtual void addHeader(const Common::String &header)
virtual NetworkReadStreamResponse execute()
void wait(int spinlockDelay=5)
void restart() override
const NetworkReadStream * getNetworkReadStream() const
Definition: networkreadstream.h:37
Definition: request.h:119
Definition: request.h:47