net-cpp: core::net::http::Request Class Reference

net-cpp .. C++11 library for networking purposes

Classes | Public Types | Public Member Functions | List of all members
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 | Configuration
| The Configuration struct encapsulates all options for creating requests. More...
struct | Credentials
| The Credentials struct encapsulates username and password for basic & digest authentication. More...
struct | Errors
| The Errors struct collects the Request-specific exceptions and error modes. More...
class | Handler
| Encapsulates callbacks that can happen during request execution. More...
struct | Progress
| The Progress struct encapsulates progress information for web-resource requests. More...

## Public Types
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
| 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. 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 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 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

## ◆ ~Request()

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

## 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.

## ◆ 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.

## ◆ operator=()

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

## ◆ operator==()

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

## ◆ 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.

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

- /home/odroid/lomiri/net-cpp-git/src/net-cpp/include/core/net/http/request.h