OpenAnima 0.2.0
Middleware for conversational NPCs that interact with the player, the world and each other
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
OpenAnima::Http::HttpTransport Class Referenceabstract

#include <HttpTransport.h>

Inheritance diagram for OpenAnima::Http::HttpTransport:
OpenAnima::Http::CurlHttpTransport

Public Member Functions

 HttpTransport (const HttpTransport &)=delete
 Transports are used through a pointer, so copying and moving are not offered.
 
HttpTransport & operator= (const HttpTransport &)=delete
 
 HttpTransport (HttpTransport &&)=delete
 
HttpTransport & operator= (HttpTransport &&)=delete
 
virtual long post (const HttpRequest &request, const ResponseObserver &observer)=0
 
HttpResponse post (const HttpRequest &request)
 

Protected Member Functions

 HttpTransport ()=default
 Only derived classes build a transport.
 

Detailed Description

The HTTP boundary of the library. Providers depend on this interface and never on a concrete client library, which keeps them testable with an in-memory implementation and keeps the socket code in a single place.

Member Function Documentation

◆ post() [1/2]

HttpResponse OpenAnima::Http::HttpTransport::post ( const HttpRequest &  request)

Performs a blocking POST and returns the whole answer.

Parameters
requestFully built request.
Returns
The status and the body, buffered.
Exceptions
TransportErrorwhen the exchange cannot be completed at all.

◆ post() [2/2]

virtual long OpenAnima::Http::HttpTransport::post ( const HttpRequest &  request,
const ResponseObserver &  observer 
)
pure virtual

Performs a blocking POST and reports the answer while it arrives. A non-2xx status is not a failure here: it is reported through the observer and returned, so the caller decides what it means.

Parameters
requestFully built request.
observerWhere the status and the body go.
Returns
The status the endpoint answered with, or 0 when it reported none.
Exceptions
TransportErrorwhen the exchange cannot be completed at all.

A class that implements this one keeps the buffered overload below reachable through its own type: the implementations here bring it in, and anything else can either do the same with using HttpTransport::post; or forward to it.

Implemented in OpenAnima::Http::CurlHttpTransport.

Referenced by OpenAnima::Http::CurlHttpTransport::post().


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