olp-cpp-sdk  1.21.0
Public Member Functions | List of all members
olp::client::HttpResponse Class Reference

This class represents the HTTP response created from the NetworkResponse and the request body. More...

#include <HttpResponse.h>

Public Member Functions

 HttpResponse (int status, std::string response={})
 Creates the HttpResponse instance. More...
 
 HttpResponse (int status, std::stringstream &&response)
 Creates the HttpResponse instance. More...
 
 HttpResponse (int status, std::stringstream &&response, http::Headers headers)
 Creates the HttpResponse instance. More...
 
 HttpResponse (const HttpResponse &other)
 A copy constructor. More...
 
HttpResponseoperator= (const HttpResponse &other)
 A copy assignment operator. More...
 
 HttpResponse (HttpResponse &&)=default
 A default move constructor.
 
HttpResponseoperator= (HttpResponse &&)=default
 A default move assignment operator.
 
void GetResponse (std::vector< unsigned char > &output)
 Copy HttpResponse content to a vector of unsigned chars. More...
 
void GetResponse (std::string &output) const
 Copy HttpResponse content to a string. More...
 
std::vector< unsigned char > GetResponseAsBytes ()
 Get the response body as a vector of unsigned chars. More...
 
std::string GetResponseAsString () const
 Renders HttpResponse content to a string. More...
 
std::stringstream & GetRawResponse ()
 Return the reference to the response object. More...
 
const http::HeadersGetHeaders () const
 Return the const reference to the response headers. More...
 
int GetStatus () const
 Return the response status. More...
 
void SetNetworkStatistics (NetworkStatistics network_statistics)
 Set NetworkStatistics. More...
 
const NetworkStatisticsGetNetworkStatistics () const
 Get the NetworkStatistics. More...
 

Detailed Description

This class represents the HTTP response created from the NetworkResponse and the request body.

Constructor & Destructor Documentation

◆ HttpResponse() [1/4]

olp::client::HttpResponse::HttpResponse ( int  status,
std::string  response = {} 
)
inline

Creates the HttpResponse instance.

Parameters
statusThe HTTP status.
responseThe response body.

◆ HttpResponse() [2/4]

olp::client::HttpResponse::HttpResponse ( int  status,
std::stringstream &&  response 
)
inline

Creates the HttpResponse instance.

Parameters
statusThe HTTP status.
responseThe response body.

◆ HttpResponse() [3/4]

olp::client::HttpResponse::HttpResponse ( int  status,
std::stringstream &&  response,
http::Headers  headers 
)
inline

Creates the HttpResponse instance.

Parameters
statusThe HTTP status.
responseThe response body.
headersResponse headers.

◆ HttpResponse() [4/4]

olp::client::HttpResponse::HttpResponse ( const HttpResponse other)
inline

A copy constructor.

This copy constructor creates a deep copy of the response body if a non-shareable container type is used.

Parameters
otherThe instance of HttpStatus to copy from.

Member Function Documentation

◆ GetHeaders()

const http::Headers& olp::client::HttpResponse::GetHeaders ( ) const
inline

Return the const reference to the response headers.

Returns
The const reference to the headers vector.

◆ GetNetworkStatistics()

const NetworkStatistics& olp::client::HttpResponse::GetNetworkStatistics ( ) const
inline

Get the NetworkStatistics.

Returns
Instance of NetworkStatistics previously set.

◆ GetRawResponse()

std::stringstream& olp::client::HttpResponse::GetRawResponse ( )
inline

Return the reference to the response object.

Returns
The reference to the response object.

◆ GetResponse() [1/2]

void olp::client::HttpResponse::GetResponse ( std::string &  output) const
inline

Copy HttpResponse content to a string.

Parameters
outputReference to a string.

◆ GetResponse() [2/2]

void olp::client::HttpResponse::GetResponse ( std::vector< unsigned char > &  output)
inline

Copy HttpResponse content to a vector of unsigned chars.

Parameters
outputReference to a vector.

◆ GetResponseAsBytes()

std::vector<unsigned char> olp::client::HttpResponse::GetResponseAsBytes ( )
inline

Get the response body as a vector of unsigned chars.

Returns
The response body as a vector of unsigned chars.

◆ GetResponseAsString()

std::string olp::client::HttpResponse::GetResponseAsString ( ) const
inline

Renders HttpResponse content to a string.

Returns
String representation of the response.

◆ GetStatus()

int olp::client::HttpResponse::GetStatus ( ) const
inline

Return the response status.

The response status can either be an ErrorCode if negative or a HttpStatusCode if positive.

Returns
The response status.

◆ operator=()

HttpResponse& olp::client::HttpResponse::operator= ( const HttpResponse other)
inline

A copy assignment operator.

This copy assignment operator creates a deep copy of the response body if a non-shareable container type is used.

Parameters
otherThe instance of HttpStatus to copy from.

◆ SetNetworkStatistics()

void olp::client::HttpResponse::SetNetworkStatistics ( NetworkStatistics  network_statistics)
inline

Set NetworkStatistics.

Parameters
network_statisticsInstance of NetworkStatistics.

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