LuciadCPillar 2023.1.04
luciad::HttpRequest::Builder Class Referencefinal

A builder of luciad::HttpRequests. More...

#include <luciad/net/http/HttpRequest.h>

Public Member Functions

 Builder (Builder &&other) noexcept
 
 Builder (const Builder &other)
 
 ~Builder ()
 
Builderbody (DataEntity body)
 Sets the HTTP request content. More...
 
HttpRequest build () const
 Returns an luciad::HttpRequest, based on the properties set on this builder. More...
 
Builderheader (HttpHeader header)
 Sets the given http header to the set of headers for this request. More...
 
Builderheader (std::string name, std::string value)
 Sets the given name value pair to the set of headers for this request. More...
 
Buildermethod (HttpRequestMethod method)
 Sets the request method of this builder. More...
 
BuilderqueryParameter (std::string name, std::string value)
 Sets the given name value pair to the set of query parameters for this request. More...
 
BuilderqueryParameter (UriQueryParameter queryParameter)
 Sets the given query parameter to the set of query parameters for this request. More...
 
Builderuri (std::string uri)
 Sets this HttpRequest's request URI. More...
 

Detailed Description

A builder of luciad::HttpRequests.

Instances of HttpRequest::Builder are created by calling luciad::HttpRequest::newBuilder.

The builder can be used to configure the request URI, the request method (default is GET unless explicitly set), specific request headers, etc. The build method returns a new luciad::HttpRequest each time it is invoked. Once built an HttpRequest is immutable.

Since
2023.0

Constructor & Destructor Documentation

◆ ~Builder()

luciad::HttpRequest::Builder::~Builder ( )

◆ Builder() [1/2]

luciad::HttpRequest::Builder::Builder ( const Builder other)

◆ Builder() [2/2]

luciad::HttpRequest::Builder::Builder ( Builder &&  other)
noexcept

Member Function Documentation

◆ body()

Builder & luciad::HttpRequest::Builder::body ( DataEntity  body)

Sets the HTTP request content.

This parameter is optional unless this HttpRequest's method has been set to POST or PUT. If not set when the request method is POST or PUT, HttpRequest::Builder::build will throw an exception.

Parameters
bodythe request content.
Returns
this builder.

◆ build()

HttpRequest luciad::HttpRequest::Builder::build ( ) const

Returns an luciad::HttpRequest, based on the properties set on this builder.

Returns
an luciad::HttpRequest, based on the properties set on this builder.
Exceptions
luciad::LogicExceptionif a URI has not been set.

◆ header() [1/2]

Builder & luciad::HttpRequest::Builder::header ( HttpHeader  header)

Sets the given http header to the set of headers for this request.

Parameters
headeran luciad::HttpHeader.
Returns
this builder.

◆ header() [2/2]

Builder & luciad::HttpRequest::Builder::header ( std::string  name,
std::string  value 
)

Sets the given name value pair to the set of headers for this request.

Parameters
nameheader name
valueheader value
Returns
this builder.

◆ method()

Builder & luciad::HttpRequest::Builder::method ( HttpRequestMethod  method)

Sets the request method of this builder.

This parameter is optional. If not set, default is GET.

Parameters
methodthe method to use.
Returns
this builder.

◆ queryParameter() [1/2]

Builder & luciad::HttpRequest::Builder::queryParameter ( std::string  name,
std::string  value 
)

Sets the given name value pair to the set of query parameters for this request.

Parameters
namequery parameter name.
valuequery parameter value.
Returns
this builder.

◆ queryParameter() [2/2]

Builder & luciad::HttpRequest::Builder::queryParameter ( UriQueryParameter  queryParameter)

Sets the given query parameter to the set of query parameters for this request.

Parameters
queryParameteran luciad::UriQueryParameter.
Returns
this builder.

◆ uri()

Builder & luciad::HttpRequest::Builder::uri ( std::string  uri)

Sets this HttpRequest's request URI.

The provided URI can have a query string. This parameter is mandatory. If it is not set, HttpRequest::Builder::build will throw an exception.

Parameters
urirequest URI string.
Returns
this builder.