19#ifndef CORE_NET_HTTP_REQUEST_H_
20#define CORE_NET_HTTP_REQUEST_H_
143 ErrorHandler error_handler{};
215 } authentication_handler;
234 virtual void set_timeout(
const std::chrono::milliseconds& timeout) = 0;
Encapsulates callbacks that can happen during request execution.
const ProgressHandler & on_progress() const
Returns the currently set progress handler.
Handler & on_response(const ResponseHandler &handler)
Adjusts the currently set response handler.
const ErrorHandler & on_error() const
Returns the currently set error handler.
Handler & on_error(const ErrorHandler &handler)
Adjusts the currently set error handler.
const ResponseHandler & on_response() const
Returns the currently set response handler.
Handler & on_progress(const ProgressHandler &handler)
Adjusts the currently set progress handler.
The Request class encapsulates a request for a web resource.
virtual ~Request()=default
virtual Response execute(const ProgressHandler &ph)=0
Synchronously executes the request.
virtual std::string url_escape(const std::string &s)=0
Returns the input string in URL-escaped format.
virtual State state()=0
state queries the current state of the operation.
Request(const Request &)=delete
virtual std::string url_unescape(const std::string &s)=0
Returns the input string in URL-unescaped format.
State
The State enum describes the different states a request can be in.
virtual void async_execute(const Handler &handler)=0
Asynchronously executes the request, reporting errors, progress and completion to the given handlers.
std::function< Credentials(const std::string &)> AuthenicationHandler
std::function< void(const Response &)> ResponseHandler
ResponseHandler is invoked when a request completes.
bool operator==(const Request &) const =delete
Request & operator=(const Request &)=delete
std::function< Progress::Next(const Progress &)> ProgressHandler
ProgressHandler is invoked for progress updates while executing the request.
virtual void set_timeout(const std::chrono::milliseconds &timeout)=0
Adjusts the timeout of a State::ready request.
std::function< void(const core::net::Error &)> ErrorHandler
ErrorHandler is invoked in case of errors arising while executing the request.
The Configuration struct encapsulates all options for creating requests.
ProgressHandler on_progress
static Configuration from_uri_as_string(const std::string &uri)
from_uri_as_string creates a new instance of Configuration for a url.
AuthenicationHandler for_http
AuthenicationHandler for_proxy
ResponseHandler on_response
The Credentials struct encapsulates username and password for basic & digest authentication.
AlreadyActive is thrown when *execute is called on an active request.
AlreadyActive(const core::Location &loc)
AlreadyActive creates a new instance with a location hint.
The Errors struct collects the Request-specific exceptions and error modes.
The Progress struct encapsulates progress information for web-resource requests.
Next
The Next enum summarizes the available return-types for the progress callback.
The Response struct models a response to a core::net::http::Request.
#define CORE_NET_DLL_PUBLIC