2016-05-24 11:57:49 +06:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BACKENDS_NETWORKING_CURL_CURLREQUEST_H
|
|
|
|
#define BACKENDS_NETWORKING_CURL_CURLREQUEST_H
|
|
|
|
|
|
|
|
#include "backends/networking/curl/request.h"
|
|
|
|
#include "common/str.h"
|
2016-05-27 01:09:10 +06:00
|
|
|
#include "common/array.h"
|
2016-05-24 11:57:49 +06:00
|
|
|
|
|
|
|
struct curl_slist;
|
|
|
|
|
|
|
|
namespace Networking {
|
|
|
|
|
|
|
|
class NetworkReadStream;
|
|
|
|
|
2016-05-27 15:21:06 +06:00
|
|
|
typedef Response<NetworkReadStream *> NetworkReadStreamResponse;
|
|
|
|
typedef Common::BaseCallback<NetworkReadStreamResponse> *NetworkReadStreamCallback;
|
|
|
|
|
2016-05-24 11:57:49 +06:00
|
|
|
class CurlRequest: public Request {
|
|
|
|
protected:
|
2016-05-27 01:09:10 +06:00
|
|
|
Common::String _url;
|
2016-05-24 11:57:49 +06:00
|
|
|
NetworkReadStream *_stream;
|
|
|
|
curl_slist *_headersList;
|
|
|
|
Common::String _postFields;
|
2016-05-30 02:23:29 +06:00
|
|
|
byte *_bytesBuffer;
|
|
|
|
uint32 _bytesBufferSize;
|
2016-05-31 14:18:32 +06:00
|
|
|
bool _uploading; //using PUT method
|
2016-06-08 16:46:18 +06:00
|
|
|
bool _usingPatch; //using PATCH method
|
2016-05-30 02:23:29 +06:00
|
|
|
|
|
|
|
virtual NetworkReadStream *makeStream();
|
2016-05-24 11:57:49 +06:00
|
|
|
|
|
|
|
public:
|
2016-05-31 01:51:32 +06:00
|
|
|
CurlRequest(DataCallback cb, ErrorCallback ecb, Common::String url);
|
2016-05-24 11:57:49 +06:00
|
|
|
virtual ~CurlRequest();
|
|
|
|
|
2016-05-26 19:09:06 +06:00
|
|
|
virtual void handle();
|
2016-05-26 17:56:13 +06:00
|
|
|
virtual void restart();
|
2016-05-24 11:57:49 +06:00
|
|
|
|
2016-05-27 15:21:06 +06:00
|
|
|
/** Replaces all headers with the passed array of headers. */
|
2016-05-26 21:40:01 +06:00
|
|
|
virtual void setHeaders(Common::Array<Common::String> &headers);
|
2016-05-27 15:21:06 +06:00
|
|
|
|
|
|
|
/** Adds a header into headers list. */
|
2016-05-26 21:40:01 +06:00
|
|
|
virtual void addHeader(Common::String header);
|
2016-05-27 15:21:06 +06:00
|
|
|
|
|
|
|
/** Adds a post field (key=value pair). */
|
2016-05-26 21:40:01 +06:00
|
|
|
virtual void addPostField(Common::String field);
|
2016-05-24 11:57:49 +06:00
|
|
|
|
2016-05-30 02:23:29 +06:00
|
|
|
/** Sets bytes buffer. */
|
|
|
|
virtual void setBuffer(byte *buffer, uint32 size);
|
|
|
|
|
2016-05-31 14:18:32 +06:00
|
|
|
/** Remembers to use PUT method when it would create NetworkReadStream. */
|
|
|
|
virtual void usePut();
|
|
|
|
|
2016-06-08 16:46:18 +06:00
|
|
|
/** Remembers to use PATCH method when it would create NetworkReadStream. */
|
|
|
|
virtual void usePatch();
|
|
|
|
|
2016-05-27 15:21:06 +06:00
|
|
|
/**
|
2016-05-28 20:10:38 +02:00
|
|
|
* Starts this Request with ConnMan.
|
|
|
|
* @return its NetworkReadStream in NetworkReadStreamResponse.
|
|
|
|
*/
|
2016-05-27 15:21:06 +06:00
|
|
|
virtual NetworkReadStreamResponse execute();
|
2016-05-27 17:50:27 +06:00
|
|
|
|
|
|
|
/** Returns Request's NetworkReadStream. */
|
2016-05-31 01:51:32 +06:00
|
|
|
const NetworkReadStream *getNetworkReadStream() const;
|
2016-05-24 11:57:49 +06:00
|
|
|
};
|
|
|
|
|
2016-05-28 20:10:38 +02:00
|
|
|
} // End of namespace Networking
|
2016-05-24 11:57:49 +06:00
|
|
|
|
|
|
|
#endif
|