ofxHTTP
A collection of tools for HTTP.
ofx::HTTP::Client Class Reference

A base HTTP cient for executing HTTP client requests. More...

#include <Client.h>

Inheritance diagram for ofx::HTTP::Client:
ofx::HTTP::AbstractRequestResponseFilter ofx::HTTP::AbstractRequestFilter ofx::HTTP::AbstractResponseFilter ofx::HTTP::OAuth10HTTPClient ofx::HTTP::OAuth20HTTPClient ofx::HTTP::SimpleClient

Public Member Functions

 Client ()
 Create a Client.
 
virtual ~Client ()
 Destroy the Client.
 
virtual Contextcontext ()
 Access the local context for the client. More...
 
std::unique_ptr< Responseexecute (Request &request)
 Execute an HTTP Request with the default client context. More...
 
std::unique_ptr< Responseexecute (Context &context, Request &request)
 Execute an HTTP Request with the given context. More...
 
void submit (Request &request)
 Execute an HTTP Request with the default client context. More...
 
void submit (Context &context, Request &request)
 Execute an HTTP Request with the given context. More...
 
template<typename ReturnType >
ReturnType execute (Context &context, Request &request, ResponseHandler< ReturnType > &handler)
 
template<typename ReturnType >
ReturnType execute (Context &context, Request &request, std::function< ReturnType(Context &, Request &, Response &)> f)
 
template<typename ReturnType >
ReturnType execute (Context &context, Request &request, std::function< ReturnType(Response &)> f)
 

Protected Member Functions

virtual void requestFilter (Context &context, Request &request) const override
 
virtual void responseFilter (Context &context, Request &request, Response &response) const override
 

Detailed Description

A base HTTP cient for executing HTTP client requests.

Member Function Documentation

◆ context()

Context & ofx::HTTP::Client::context ( )
virtual

Access the local context for the client.

The context is used when a context is not provided to the executing function.

Returns
a reference to the default context.

◆ execute() [1/2]

std::unique_ptr< Response > ofx::HTTP::Client::execute ( Request request)

Execute an HTTP Request with the default client context.

Parameters
requestThe request to execute.
Returns
a unique pointer with the response.
Exceptions
Variousexceptions.

◆ execute() [2/2]

std::unique_ptr< Response > ofx::HTTP::Client::execute ( Context context,
Request request 
)

Execute an HTTP Request with the given context.

Parameters
contextThe execution context to use.
requestThe request to execute.
Returns
a unique pointer with the response.
Exceptions
Variousexceptions.

◆ submit() [1/2]

void ofx::HTTP::Client::submit ( Request request)

Execute an HTTP Request with the default client context.

This does not throw exceptions but sends everything to listeners in the default context. e.g.

context.events.onHTTPClientStateChange
context.events.onHTTPClientRequestProgress
context.events.onHTTPClientResponseProgress
context.events.onHTTPClientResponseStream
context.events.onHTTPClientError
...
Parameters
requestThe request to execute.

◆ submit() [2/2]

void ofx::HTTP::Client::submit ( Context context,
Request request 
)

Execute an HTTP Request with the given context.

This does not throw exceptions but sends everything to listeners in the given context. e.g.

context.events.onHTTPClientStateChange
context.events.onHTTPClientRequestProgress
context.events.onHTTPClientResponseProgress
context.events.onHTTPClientResponseStream
context.events.onHTTPClientError
...
Parameters
contextThe execution context to use.
requestThe request to execute.

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