streaming_request.h
Go to the documentation of this file.
/*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
* Gary Wang <gary.wang@canonical.com>
*/
#ifndef CORE_NET_HTTP_STREAMING_REQUEST_H_
#define CORE_NET_HTTP_STREAMING_REQUEST_H_
#include <core/net/http/request.h>
namespace core
{
namespace net
{
namespace http
{
class CORE_NET_DLL_PUBLIC StreamingRequest : public Request
{
public:
typedef std::function<void(const std::string&)> DataHandler;
using Request::execute;
virtual Response execute(const ProgressHandler& ph, const DataHandler& dh) = 0;
using Request::async_execute;
virtual void async_execute(const Handler& handler, const DataHandler& dh) = 0;
virtual void pause() = 0;
virtual void resume() = 0;
virtual void abort_request_if(std::uint64_t limit, const std::chrono::seconds& time) = 0;
};
}
}
}
#endif // CORE_NET_HTTP_STREAMING_REQUEST_H_
core::net::http::Request::Handler
Encapsulates callbacks that can happen during request execution.
Definition request.h:120
core::net::http::Request::execute
virtual Response execute(const ProgressHandler &ph)=0
Synchronously executes the request.
core::net::http::Request::Request
Request(const Request &)=delete
core::net::http::Request::async_execute
virtual void async_execute(const Handler &handler)=0
Asynchronously executes the request, reporting errors, progress and completion to the given handlers.
core::net::http::Request::ProgressHandler
std::function< Progress::Next(const Progress &)> ProgressHandler
ProgressHandler is invoked for progress updates while executing the request.
Definition request.h:109
core::net::http::StreamingRequest
The StreamingRequest class encapsulates a request for a web resource, streaming data to the receiver ...
Definition streaming_request.h:35
core::net::http::StreamingRequest::resume
virtual void resume()=0
Resume the request.
core::net::http::StreamingRequest::pause
virtual void pause()=0
Pause the request with options for aborting the request. The request will be aborted if transfer spee...
core::net::http::StreamingRequest::async_execute
virtual void async_execute(const Handler &handler, const DataHandler &dh)=0
core::net::http::StreamingRequest::abort_request_if
virtual void abort_request_if(std::uint64_t limit, const std::chrono::seconds &time)=0
Sets options for aborting the request. The request will be aborted if transfer speed belows limit byt...
core::net::http::StreamingRequest::execute
virtual Response execute(const ProgressHandler &ph, const DataHandler &dh)=0
core::net::http::StreamingRequest::DataHandler
std::function< void(const std::string &)> DataHandler
Definition streaming_request.h:39
core::net::http
Definition client.h:39
core::net
Definition error.h:28
core
Definition location.h:24
request.h
core::net::http::Response
The Response struct models a response to a core::net::http::Request.
Definition response.h:40
CORE_NET_DLL_PUBLIC
#define CORE_NET_DLL_PUBLIC
Definition visibility.h:25