ScummVM API documentation
networkreadstream.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_NETWORKREADSTREAM_H
23#define BACKENDS_NETWORKING_HTTP_NETWORKREADSTREAM_H
24
25#include "common/array.h"
26#include "common/hash-str.h"
27#include "common/hashmap.h"
28#include "common/memstream.h"
29#include "common/path.h"
30#include "common/str.h"
31#include "common/stream.h"
32
33namespace Networking {
34typedef Common::Array<Common::String> RequestHeaders;
35
36// Simple interface for platform-specific NetworkReadStream implementations
38protected:
39 bool _keepAlive;
40 long _keepAliveIdle, _keepAliveInterval;
41 bool _eos;
42
43 NetworkReadStream(bool keepAlive, long keepAliveIdle, long keepAliveInterval)
44 : _eos(false), _keepAlive(keepAlive),
45 _keepAliveIdle(keepAliveIdle), _keepAliveInterval(keepAliveInterval) {
46 }
47
48public:
49 /* Implementation-defined Constructors */
50
52 static NetworkReadStream *make(const char *url, RequestHeaders *headersList, const Common::String &postFields,
53 bool uploading = false, bool usingPatch = false,
54 bool keepAlive = false, long keepAliveIdle = 120, long keepAliveInterval = 60);
55
57 static NetworkReadStream *make(const char *url, RequestHeaders *headersList,
59 bool keepAlive = false, long keepAliveIdle = 120, long keepAliveInterval = 60);
60
62 static NetworkReadStream *make(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize,
63 bool uploading = false, bool usingPatch = false, bool post = true,
64 bool keepAlive = false, long keepAliveIdle = 120, long keepAliveInterval = 60);
65
67 virtual bool reuse(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading = false, bool usingPatch = false) = 0;
69 virtual bool reuse(
70 const char *url, RequestHeaders *headersList,
74 virtual bool reuse(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading = false, bool usingPatch = false, bool post = true) = 0;
85 bool eos() const override { return _eos; }
86
99 uint32 read(void *dataPtr, uint32 dataSize) override = 0;
100
107 virtual long httpResponseCode() const = 0;
108
115 virtual Common::String currentLocation() const = 0;
116
124
126 virtual double getProgress() const = 0;
127
128 bool keepAlive() const { return _keepAlive; }
129
130 virtual bool hasError() const = 0;
131 virtual const char *getError() const = 0;
132};
133
134} // End of namespace Networking
135
136#endif
Definition: stream.h:385
Definition: str.h:59
Definition: networkreadstream.h:37
static NetworkReadStream * make(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading=false, bool usingPatch=false, bool post=true, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)
static NetworkReadStream * make(const char *url, RequestHeaders *headersList, const Common::HashMap< Common::String, Common::String > &formFields, const Common::HashMap< Common::String, Common::Path > &formFiles, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)
virtual bool reuse(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false)=0
uint32 read(void *dataPtr, uint32 dataSize) override=0
static NetworkReadStream * make(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)
bool eos() const override
Definition: networkreadstream.h:85
virtual Common::HashMap< Common::String, Common::String > responseHeadersMap() const =0
virtual bool reuse(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading=false, bool usingPatch=false, bool post=true)=0
virtual bool reuse(const char *url, RequestHeaders *headersList, const Common::HashMap< Common::String, Common::String > &formFields, const Common::HashMap< Common::String, Common::Path > &formFiles)=0
virtual Common::String currentLocation() const =0
virtual double getProgress() const =0
virtual long httpResponseCode() const =0