olp-cpp-sdk  1.18.1
Public Member Functions | Public Attributes | 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...
 
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...
 

Public Attributes

int status {static_cast<int>(olp::http::ErrorCode::UNKNOWN_ERROR)}
 
std::stringstream response
 
http::Headers headers
 

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.

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

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

Member Data Documentation

◆ headers

http::Headers olp::client::HttpResponse::headers

HTTP headers.

Deprecated:
: This field will be marked as private by 01.2021. Please do not use directly, use GetHeaders() method instead.

◆ response

std::stringstream olp::client::HttpResponse::response

The HTTP response.

Deprecated:
: This field will be marked as private by 01.2021. Please do not use directly, use GetResponse() methods instead.

◆ status

int olp::client::HttpResponse::status {static_cast<int>(olp::http::ErrorCode::UNKNOWN_ERROR)}

The HTTP Status. This can be either a ErrorCode if negative or a HttpStatusCode if positive.

Deprecated:
: This field will be marked as private by 01.2021. Please do not use directly, use GetStatus() method instead.

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