olp-cpp-sdk 1.25.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
olp::http::NetworkRequest Class Referencefinal

A network request abstraction for an HTTP request. More...

#include <NetworkRequest.h>

Public Types

enum class  HttpVerb {
  GET = 0 , POST = 1 , HEAD = 2 , PUT = 3 ,
  DEL = 4 , PATCH = 5 , OPTIONS = 6
}
 The HTTP method, as specified at https://tools.ietf.org/html/rfc2616. More...
 
using RequestBodyType = std::shared_ptr< const std::vector< std::uint8_t > >
 An alias for the HTTP request body.
 

Public Member Functions

 NetworkRequest (std::string url)
 Creates the NetworkRequest instance.
 
const Headers & GetHeaders () const
 Gets all HTTP headers.
 
Headers & GetMutableHeaders ()
 Gets the mutable reference to the HTTP headers.
 
NetworkRequest & WithHeader (std::string name, std::string value)
 Adds an extra HTTP header.
 
const std::string & GetUrl () const
 Gets the request URL.
 
NetworkRequest & WithUrl (std::string url)
 Sets the request URL.
 
HttpVerb GetVerb () const
 Gets the HTTP method.
 
NetworkRequest & WithVerb (HttpVerb verb)
 Sets the HTTP method.
 
RequestBodyType GetBody () const
 Gets the request body.
 
NetworkRequest & WithBody (RequestBodyType body)
 Sets the request body.
 
const NetworkSettings & GetSettings () const
 Gets the network settings for this request.
 
NetworkRequest & WithSettings (NetworkSettings settings)
 Sets network settings for this request.
 

Detailed Description

A network request abstraction for an HTTP request.

Member Enumeration Documentation

◆ HttpVerb

The HTTP method, as specified at https://tools.ietf.org/html/rfc2616.

Enumerator
GET 

The GET method (RFC2616, section-9.3).

POST 

The POST method (RFC2616, section-9.5).

HEAD 

The HEAD method (RFC2616 section-9.4).

PUT 

The PUT method (RFC2616 section-9.6).

DEL 

The DELETE method (RFC2616 section-9.7).

PATCH 

The PATCH method (RFC2068 section-19.6.1.1).

OPTIONS 

The OPTIONS method (RFC2616 section-9.2).

Constructor & Destructor Documentation

◆ NetworkRequest()

olp::http::NetworkRequest::NetworkRequest ( std::string  url)
explicit

Creates the NetworkRequest instance.

Parameters
[in]urlThe URL of the HTTP request.

Member Function Documentation

◆ GetBody()

RequestBodyType olp::http::NetworkRequest::GetBody ( ) const

Gets the request body.

Returns
The shared pointer to the vector that contains the request body.

◆ GetHeaders()

const Headers & olp::http::NetworkRequest::GetHeaders ( ) const

Gets all HTTP headers.

Returns
The vector of the HTTP headers.

◆ GetMutableHeaders()

Headers & olp::http::NetworkRequest::GetMutableHeaders ( )

Gets the mutable reference to the HTTP headers.

Returns
The mutable reference to vector of the HTTP headers.

◆ GetSettings()

const NetworkSettings & olp::http::NetworkRequest::GetSettings ( ) const

Gets the network settings for this request.

Returns
The NetworkSettings object.

◆ GetUrl()

const std::string & olp::http::NetworkRequest::GetUrl ( ) const

Gets the request URL.

Returns
The request URL.

◆ GetVerb()

HttpVerb olp::http::NetworkRequest::GetVerb ( ) const

Gets the HTTP method.

Returns
The HTTP method.

◆ WithBody()

NetworkRequest & olp::http::NetworkRequest::WithBody ( RequestBodyType  body)

Sets the request body.

Parameters
[in]bodyThe shared pointer to the vector that contains the request body.
Returns
A reference to *this.

◆ WithHeader()

NetworkRequest & olp::http::NetworkRequest::WithHeader ( std::string  name,
std::string  value 
)

Adds an extra HTTP header.

Parameters
[in]nameThe header name.
[in]valueThe header value.
Returns
A reference to *this.

◆ WithSettings()

NetworkRequest & olp::http::NetworkRequest::WithSettings ( NetworkSettings  settings)

Sets network settings for this request.

Parameters
[in]settingsThe NetworkRequest instance.
Returns
A reference to *this.

◆ WithUrl()

NetworkRequest & olp::http::NetworkRequest::WithUrl ( std::string  url)

Sets the request URL.

Parameters
[in]urlThe request URL.
Returns
A reference to *this.

◆ WithVerb()

NetworkRequest & olp::http::NetworkRequest::WithVerb ( HttpVerb  verb)

Sets the HTTP method.

Parameters
[in]verbThe HTTP method.
Returns
A reference to *this.

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