net-cpp ..
C++11 library for networking purposes
streaming_request.h
Go to the documentation of this file.
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 * Gary Wang <gary.wang@canonical.com>
18 */
19#ifndef CORE_NET_HTTP_STREAMING_REQUEST_H_
20#define CORE_NET_HTTP_STREAMING_REQUEST_H_
21
23
24namespace core
25{
26namespace net
27{
28namespace http
29{
35{
36public:
37
39 typedef std::function<void(const std::string&)> DataHandler;
40
47 virtual Response execute(const ProgressHandler& ph, const DataHandler& dh) = 0;
48
55 virtual void async_execute(const Handler& handler, const DataHandler& dh) = 0;
56
62 virtual void pause() = 0;
63
68 virtual void resume() = 0;
69
76 virtual void abort_request_if(std::uint64_t limit, const std::chrono::seconds& time) = 0;
77};
78}
79}
80}
81
82#endif // CORE_NET_HTTP_STREAMING_REQUEST_H_
Encapsulates callbacks that can happen during request execution.
Definition request.h:120
The Request class encapsulates a request for a web resource.
Definition request.h:42
std::function< Progress::Next(const Progress &)> ProgressHandler
ProgressHandler is invoked for progress updates while executing the request.
Definition request.h:109
The StreamingRequest class encapsulates a request for a web resource, streaming data to the receiver ...
virtual void resume()=0
Resume the request.
virtual void pause()=0
Pause the request with options for aborting the request. The request will be aborted if transfer spee...
virtual void async_execute(const Handler &handler, const DataHandler &dh)=0
Asynchronously executes the request, reporting errors, progress and completion to the given handlers.
std::function< void(const std::string &)> DataHandler
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...
virtual Response execute(const ProgressHandler &ph, const DataHandler &dh)=0
Synchronously executes the request.
The Response struct models a response to a core::net::http::Request.
Definition response.h:40
#define CORE_NET_DLL_PUBLIC
Definition visibility.h:25