core::net::http::Request Class Referenceabstract

The Request class encapsulates a request for a web resource. More...

`#include <request.h>`

Inheritance diagram for core::net::http::Request:
Collaboration diagram for core::net::http::Request:

## Classes

struct | Errors
| The Errors struct collects the Request-specific exceptions and error modes. More...
struct | Progress
| The Progress struct encapsulates progress information for web-resource requests. More...
class | Handler
| Encapsulates callbacks that can happen during request execution. More...
struct | Credentials
| The Credentials struct encapsulates username and password for basic & digest authentication. More...
struct | Configuration
| The Configuration struct encapsulates all options for creating requests. More...

## Public Types

enum class | State { ready , active , 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.
typedef std::function< Progress::Next(const Progress &)> | ProgressHandler
| ProgressHandler is invoked for progress updates while executing the request.
typedef std::function< void(const Response &)> | ResponseHandler
| ResponseHandler is invoked when a request completes.
typedef std::function< Credentials(const std::string &)> | AuthenicationHandler

## Public Member Functions

| Request (const Request &)=delete
virtual | ~Request ()=default
Request & | operator= (const Request &)=delete
bool | operator== (const Request &) const =delete
virtual State | state ()=0
| state queries the current state of the operation.
virtual void | set_timeout (const std::chrono::milliseconds &timeout)=0
| Adjusts the timeout of a State::ready request.
virtual Response | execute (const ProgressHandler &ph)=0
| Synchronously executes the request.
virtual void | async_execute (const Handler &handler)=0
| Asynchronously executes the request, reporting errors, progress and completion to the given handlers.
virtual std::string | url_escape (const std::string &s)=0
| Returns the input string in URL-escaped format.
virtual std::string | url_unescape (const std::string &s)=0
| Returns the input string in URL-unescaped format.

## Detailed Description

The Request class encapsulates a request for a web resource.

Definition at line 41 of file request.h.

## Member Typedef Documentation

## AuthenicationHandler

typedef std::function<Credentials(const std::string&)> core::net::http::Request::AuthenicationHandler

Function signature for querying credentials for a given URL.

Definition at line 157 of file request.h.

## ErrorHandler

typedef std::function<void(const core::net::Error&)> core::net::http::Request::ErrorHandler

ErrorHandler is invoked in case of errors arising while executing the request.

Definition at line 104 of file request.h.

## ProgressHandler

typedef std::function<Progress::Next(const Progress&)> core::net::http::Request::ProgressHandler

ProgressHandler is invoked for progress updates while executing the request.

Definition at line 109 of file request.h.

## ResponseHandler

typedef std::function<void(const Response&)> core::net::http::Request::ResponseHandler

ResponseHandler is invoked when a request completes.

Definition at line 114 of file request.h.

## Member Enumeration Documentation

## State

enum class core::net::http::Request::State

strong

The State enum describes the different states a request can be in.

Enumerator
ready | The request is idle and needs execution.
active | The request is active and is actively being executed.
done | Execution of the request has finished.

Definition at line 47 of file request.h.

## Constructor & Destructor Documentation

## Request()

core::net::http::Request::Request | ( | const Request & |  | ) |

delete

References Request().

Referenced by operator=(), operator==(), Request(), and url_unescape().

Here is the call graph for this function:

## ~Request()

virtual core::net::http::Request::~Request | ( |  | ) |

virtual default

## Member Function Documentation

## async_execute()

virtual void core::net::http::Request::async_execute | ( | const Handler & | handler | ) |

pure virtual

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

Parameters

  handler | The handlers to called for events happening during execution of the request.

Returns
  The response to the request.

Implemented in core::net::http::StreamingRequest.

Referenced by core::net::http::StreamingRequest::execute().

## execute()

virtual Response core::net::http::Request::execute | ( | const ProgressHandler & | ph | ) |

pure virtual

Synchronously executes the request.

Exceptions

  core::net::http::Error | in case of http-related errors.
  core::net::Error | in case of network-related errors.

Returns
  The response to the request.

Implemented in core::net::http::StreamingRequest.

## operator=()

Request & core::net::http::Request::operator= | ( | const Request & |  | ) |

delete

References Request().

Here is the call graph for this function:

## operator==()

bool core::net::http::Request::operator== | ( | const Request & |  | ) | const

delete

References Request().

Here is the call graph for this function:

## set_timeout()

virtual void core::net::http::Request::set_timeout | ( | const std::chrono::milliseconds & | timeout | ) |

pure virtual

Adjusts the timeout of a State::ready request.

Parameters

  timeout | The timeout in milliseconds.

## state()

virtual State core::net::http::Request::state | ( |  | ) |

pure virtual

state queries the current state of the operation.

Returns
  A value from the State enumeration.

## url_escape()

virtual std::string core::net::http::Request::url_escape | ( | const std::string & | s | ) |

pure virtual

Returns the input string in URL-escaped format.

Parameters

  s | The string to be URL escaped.

## url_unescape()

virtual std::string core::net::http::Request::url_unescape | ( | const std::string & | s | ) |

pure virtual

Returns the input string in URL-unescaped format.

Parameters

  s | The string to be URL unescaped.

References Request().

Here is the call graph for this function:

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

- request.h