OpenAnima 0.2.0
Middleware for conversational NPCs that interact with the player, the world and each other
Loading...
Searching...
No Matches
Static Public Member Functions | Public Attributes | List of all members
OpenAnima::Http::ResponseObserver Struct Reference

#include <HttpTransport.h>

Static Public Member Functions

static ResponseObserver buffering (std::string &body)
 

Public Attributes

std::function< void(long statusCode)> onStatus
 Called once the status is known and before any body arrives.
 
std::function< bool(std::string_view body)> onBody
 

Detailed Description

Watches a response while it is being received.

A buffered exchange only wants the body at the end. A streamed one, like the text/event-stream a chat-completions call answers with, wants every piece as it arrives, and wants the status before the first piece: the body of a rejected call is not a stream at all, and reading it as one hides the real error.

Both callbacks may be left empty, and are then simply not called.

Member Function Documentation

◆ buffering()

static ResponseObserver OpenAnima::Http::ResponseObserver::buffering ( std::string &  body)
static
Parameters
bodyString every piece is appended to.
Returns
An observer that buffers the body and ignores the status.

Member Data Documentation

◆ onBody

std::function<bool(std::string_view body)> OpenAnima::Http::ResponseObserver::onBody

Called for each piece of the body, in order.

Parameters
bodyBytes just received; valid only for the duration of the call.
Returns
false to stop the exchange.

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