net-cpp  ..
C++11 library for networking purposes
core::net::http::StreamingRequest Class Referenceabstract

The StreamingRequest class encapsulates a request for a web resource, streaming data to the receiver as it receives in addition to accumulating all incoming data. More...

#include <streaming_request.h>

+ Inheritance diagram for core::net::http::StreamingRequest:
+ Collaboration diagram for core::net::http::StreamingRequest:

Public Types

typedef std::function< void(const std::string &)> DataHandler
 
- Public Types inherited from core::net::http::Request
enum  State {
  State::ready,
  State::active,
  State::done
}
 The State enum describes the different states a request can be in. More...
 
typedef std::function< void(const core::net::Error &)> ErrorHandler
 ErrorHandler is invoked in case of errors arising while executing the request. More...
 
typedef std::function< Progress::Next(const Progress &)> ProgressHandler
 ProgressHandler is invoked for progress updates while executing the request. More...
 
typedef std::function< void(const Response &)> ResponseHandler
 ResponseHandler is invoked when a request completes. More...
 
typedef std::function< Credentials(const std::string &)> AuthenicationHandler
 

Public Member Functions

virtual Response execute (const ProgressHandler &ph, const DataHandler &dh)=0
 Synchronously executes the request. More...
 
virtual void async_execute (const Handler &handler, const DataHandler &dh)=0
 Asynchronously executes the request, reporting errors, progress and completion to the given handlers. More...
 
virtual void pause ()=0
 Pause the request with options for aborting the request. The request will be aborted if transfer speed falls below limit in [bytes/second] for time seconds. More...
 
virtual void resume ()=0
 Resume the request. More...
 
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 bytes per second for time seconds. More...
 
- Public Member Functions inherited from core::net::http::Request
 Request (const Request &)=delete
 
virtual ~Request ()=default
 
Requestoperator= (const Request &)=delete
 
bool operator== (const Request &) const =delete
 
virtual State state ()=0
 state queries the current state of the operation. More...
 
virtual void set_timeout (const std::chrono::milliseconds &timeout)=0
 Adjusts the timeout of a State::ready request. More...
 
virtual Response execute (const ProgressHandler &ph)=0
 Synchronously executes the request. More...
 
virtual void async_execute (const Handler &handler)=0
 Asynchronously executes the request, reporting errors, progress and completion to the given handlers. More...
 
virtual std::string url_escape (const std::string &s)=0
 Returns the input string in URL-escaped format. More...
 
virtual std::string url_unescape (const std::string &s)=0
 Returns the input string in URL-unescaped format. More...
 

Detailed Description

The StreamingRequest class encapsulates a request for a web resource, streaming data to the receiver as it receives in addition to accumulating all incoming data.

Definition at line 34 of file streaming_request.h.

Member Typedef Documentation

◆ DataHandler

typedef std::function<void(const std::string&)> core::net::http::StreamingRequest::DataHandler

DataHandler is invoked when a new chunk of data arrives from the server.

Definition at line 39 of file streaming_request.h.

Member Function Documentation

◆ abort_request_if()

virtual void core::net::http::StreamingRequest::abort_request_if ( std::uint64_t  limit,
const std::chrono::seconds &  time 
)
pure virtual

Sets options for aborting the request. The request will be aborted if transfer speed belows limit bytes per second for time seconds.

Parameters
limitThe transfer speed in seconds.
timewaiting period(seconds) to abort the request.

◆ async_execute()

virtual void core::net::http::StreamingRequest::async_execute ( const Handler handler,
const DataHandler dh 
)
pure virtual

Asynchronously executes the request, reporting errors, progress and completion to the given handlers.

Parameters
handlerThe handlers to called for events happening during execution of the request.
dhThe data handler receiving chunks of data while executing the request.
Returns
The response to the request.

◆ execute()

virtual Response core::net::http::StreamingRequest::execute ( const ProgressHandler ph,
const DataHandler dh 
)
pure virtual

Synchronously executes the request.

Exceptions
core::net::http::Errorin case of http-related errors.
core::net::Errorin case of network-related errors.
Returns
The response to the request.

◆ pause()

virtual void core::net::http::StreamingRequest::pause ( )
pure virtual

Pause the request with options for aborting the request. The request will be aborted if transfer speed falls below limit in [bytes/second] for time seconds.

Exceptions
core::net::http::Errorin case of http-related errors.

◆ resume()

virtual void core::net::http::StreamingRequest::resume ( )
pure virtual

Resume the request.

Exceptions
core::net::http::Errorin case of http-related errors.

The documentation for this class was generated from the following file: