ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

curlrequest.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef BACKENDS_NETWORKING_CURL_CURLREQUEST_H
00024 #define BACKENDS_NETWORKING_CURL_CURLREQUEST_H
00025 
00026 #include "backends/networking/curl/request.h"
00027 #include "common/str.h"
00028 #include "common/array.h"
00029 #include "common/hashmap.h"
00030 #include "common/hash-str.h"
00031 
00032 struct curl_slist;
00033 
00034 namespace Networking {
00035 
00036 class NetworkReadStream;
00037 
00038 typedef Response<NetworkReadStream *> NetworkReadStreamResponse;
00039 typedef Common::BaseCallback<NetworkReadStreamResponse> *NetworkReadStreamCallback;
00040 
00041 class CurlRequest: public Request {
00042 protected:
00043     Common::String _url;
00044     NetworkReadStream *_stream;
00045     curl_slist *_headersList;
00046     Common::String _postFields;
00047     Common::HashMap<Common::String, Common::String> _formFields;
00048     Common::HashMap<Common::String, Common::String> _formFiles;
00049     byte *_bytesBuffer;
00050     uint32 _bytesBufferSize;
00051     bool _uploading; //using PUT method
00052     bool _usingPatch; //using PATCH method
00053 
00054     virtual NetworkReadStream *makeStream();
00055 
00056 public:
00057     CurlRequest(DataCallback cb, ErrorCallback ecb, Common::String url);
00058     virtual ~CurlRequest();
00059 
00060     virtual void handle();
00061     virtual void restart();
00062     virtual Common::String date() const;
00063 
00065     virtual void setHeaders(Common::Array<Common::String> &headers);
00066 
00068     virtual void addHeader(Common::String header);
00069 
00071     virtual void addPostField(Common::String field);
00072 
00074     virtual void addFormField(Common::String name, Common::String value);
00075 
00077     virtual void addFormFile(Common::String name, Common::String filename);
00078 
00080     virtual void setBuffer(byte *buffer, uint32 size);
00081 
00083     virtual void usePut();
00084 
00086     virtual void usePatch();
00087 
00092     virtual NetworkReadStreamResponse execute();
00093 
00095     const NetworkReadStream *getNetworkReadStream() const;
00096 };
00097 
00098 } // End of namespace Networking
00099 
00100 #endif


Generated on Sat Aug 24 2019 05:00:51 for ResidualVM by doxygen 1.7.1
curved edge   curved edge