HTTP v1.13.1
Loading...
Searching...
No Matches
web::HTTPBuilder Class Reference

HTTP builder. More...

#include <HTTPBuilder.h>

Public Member Functions

 HTTPBuilder (std::string_view fullHTTPVersion="HTTP/1.1")
 
 HTTPBuilder (const HTTPBuilder &other)=default
 
 HTTPBuilder (HTTPBuilder &&other) noexcept=default
 
HTTPBuilderoperator= (const HTTPBuilder &other)=default
 
HTTPBuilderoperator= (HTTPBuilder &&other) noexcept=default
 
HTTPBuildergetRequest ()
 Set GET request.
 
HTTPBuilderpostRequest ()
 Set POST request.
 
HTTPBuilderputRequest ()
 Set PUT request.
 
HTTPBuilderheadRequest ()
 Set HEAD request.
 
HTTPBuilderoptionsRequest ()
 Set OPTIONS request.
 
HTTPBuilderdeleteRequest ()
 Set DELETE request.
 
HTTPBuilderconnectRequest ()
 Set CONNECT request.
 
HTTPBuildertraceRequest ()
 Set TRACE request.
 
HTTPBuilderpatchRequest ()
 Set PATCH request.
 
template<typename StringT , typename T , typename... Args>
HTTPBuilderqueryParameters (StringT &&name, T &&value, Args &&... args)
 Append key - value parameters.
 
template<typename... Args>
HTTPBuilderparametersWithRoute (std::string_view route, Args &&... args)
 
HTTPBuilderparameters (std::string_view parameters)
 Set parameters.
 
HTTPBuilderresponseCode (ResponseCodes code)
 
HTTPBuilderresponseCode (int code, std::string_view responseMessage)
 
HTTPBuilderHTTPVersion (std::string_view httpVersion)
 
template<typename StringT , typename T , typename... Args>
HTTPBuilderheaders (StringT &&name, T &&value, Args &&... args)
 Append header - value.
 
HTTPBuilderchunks (const std::vector< std::string > &chunks)
 
HTTPBuilderchunks (std::vector< std::string > &&chunks)
 
HTTPBuilderchunk (std::string_view chunk)
 
std::string build (std::string_view data="", const std::unordered_map< std::string, std::string > &additionalHeaders={}) const
 
std::string build (const json::JSONBuilder &builder, std::unordered_map< std::string, std::string > additionalHeaders={}) const
 
std::string build (const std::unordered_map< std::string, std::string > &urlEncoded, std::unordered_map< std::string, std::string > additionalHeaders={}) const
 
HTTPBuilderclear ()
 
HTTPBuilderpartialChunks ()
 
 ~HTTPBuilder ()=default
 

Static Public Member Functions

static std::string getChunks (const std::vector< std::string > &chunks, bool partialChunks, bool preCalculateSize=false)
 Make HTTP parsed data with zero chunk.
 
static std::string getChunk (std::string_view chunk)
 Make HTTP parsed chunk.
 

Friends

HTTP_API std::ostream & operator<< (std::ostream &outputStream, const HTTPBuilder &builder)
 Set HTTP to output stream.
 

Detailed Description

HTTP builder.

Definition at line 15 of file HTTPBuilder.h.

Constructor & Destructor Documentation

◆ HTTPBuilder() [1/3]

web::HTTPBuilder::HTTPBuilder ( std::string_view fullHTTPVersion = "HTTP/1.1")

◆ HTTPBuilder() [2/3]

web::HTTPBuilder::HTTPBuilder ( const HTTPBuilder & other)
default

◆ HTTPBuilder() [3/3]

web::HTTPBuilder::HTTPBuilder ( HTTPBuilder && other)
defaultnoexcept

◆ ~HTTPBuilder()

web::HTTPBuilder::~HTTPBuilder ( )
default

Member Function Documentation

◆ build() [1/3]

std::string web::HTTPBuilder::build ( const json::JSONBuilder & builder,
std::unordered_map< std::string, std::string > additionalHeaders = {} ) const

◆ build() [2/3]

std::string web::HTTPBuilder::build ( const std::unordered_map< std::string, std::string > & urlEncoded,
std::unordered_map< std::string, std::string > additionalHeaders = {} ) const

◆ build() [3/3]

std::string web::HTTPBuilder::build ( std::string_view data = "",
const std::unordered_map< std::string, std::string > & additionalHeaders = {} ) const

◆ chunk()

HTTPBuilder & web::HTTPBuilder::chunk ( std::string_view chunk)

Definition at line 215 of file HTTPBuilder.cpp.

◆ chunks() [1/2]

HTTPBuilder & web::HTTPBuilder::chunks ( const std::vector< std::string > & chunks)

◆ chunks() [2/2]

HTTPBuilder & web::HTTPBuilder::chunks ( std::vector< std::string > && chunks)

◆ clear()

HTTPBuilder & web::HTTPBuilder::clear ( )

Definition at line 294 of file HTTPBuilder.cpp.

◆ connectRequest()

HTTPBuilder & web::HTTPBuilder::connectRequest ( )

Set CONNECT request.

Returns
Self

Definition at line 112 of file HTTPBuilder.cpp.

◆ deleteRequest()

HTTPBuilder & web::HTTPBuilder::deleteRequest ( )

Set DELETE request.

Returns
Self

Definition at line 105 of file HTTPBuilder.cpp.

◆ getChunk()

string web::HTTPBuilder::getChunk ( std::string_view chunk)
static

Make HTTP parsed chunk.

Parameters
chunk
Returns

Definition at line 55 of file HTTPBuilder.cpp.

◆ getChunks()

string web::HTTPBuilder::getChunks ( const std::vector< std::string > & chunks,
bool partialChunks,
bool preCalculateSize = false )
static

Make HTTP parsed data with zero chunk.

Parameters
chunksData to convert
partialChunksIf true does not append 0 at the end
preCalculateSizePre allocate result string size(requires additional pass)
Returns

Definition at line 24 of file HTTPBuilder.cpp.

◆ getRequest()

HTTPBuilder & web::HTTPBuilder::getRequest ( )

Set GET request.

Returns
Self

Definition at line 70 of file HTTPBuilder.cpp.

◆ headers()

template<typename StringT , typename T , typename... Args>
HTTPBuilder & web::HTTPBuilder::headers ( StringT && name,
T && value,
Args &&... args )

Append header - value.

Template Parameters
StringT
T
...Args
Parameters
name
value
...args
Returns
Self

Definition at line 207 of file HTTPBuilder.h.

◆ headRequest()

HTTPBuilder & web::HTTPBuilder::headRequest ( )

Set HEAD request.

Returns
Self

Definition at line 91 of file HTTPBuilder.cpp.

◆ HTTPVersion()

HTTPBuilder & web::HTTPBuilder::HTTPVersion ( std::string_view httpVersion)

Definition at line 178 of file HTTPBuilder.cpp.

◆ operator=() [1/2]

HTTPBuilder & web::HTTPBuilder::operator= ( const HTTPBuilder & other)
default

◆ operator=() [2/2]

HTTPBuilder & web::HTTPBuilder::operator= ( HTTPBuilder && other)
defaultnoexcept

◆ optionsRequest()

HTTPBuilder & web::HTTPBuilder::optionsRequest ( )

Set OPTIONS request.

Returns
Self

Definition at line 98 of file HTTPBuilder.cpp.

◆ parameters()

HTTPBuilder & web::HTTPBuilder::parameters ( std::string_view parameters)

Set parameters.

Parameters
parameters
Returns
Self

Definition at line 133 of file HTTPBuilder.cpp.

◆ parametersWithRoute()

template<typename... Args>
HTTPBuilder & web::HTTPBuilder::parametersWithRoute ( std::string_view route,
Args &&... args )

Definition at line 185 of file HTTPBuilder.h.

◆ partialChunks()

HTTPBuilder & web::HTTPBuilder::partialChunks ( )

Definition at line 304 of file HTTPBuilder.cpp.

◆ patchRequest()

HTTPBuilder & web::HTTPBuilder::patchRequest ( )

Set PATCH request.

Returns
Self

Definition at line 126 of file HTTPBuilder.cpp.

◆ postRequest()

HTTPBuilder & web::HTTPBuilder::postRequest ( )

Set POST request.

Returns
Self

Definition at line 77 of file HTTPBuilder.cpp.

◆ putRequest()

HTTPBuilder & web::HTTPBuilder::putRequest ( )

Set PUT request.

Returns
Self

Definition at line 84 of file HTTPBuilder.cpp.

◆ queryParameters()

template<typename StringT , typename T , typename... Args>
HTTPBuilder & web::HTTPBuilder::queryParameters ( StringT && name,
T && value,
Args &&... args )

Append key - value parameters.

Template Parameters
StringT
T
...Args
Parameters
name
value
...args
Returns
Self

Definition at line 148 of file HTTPBuilder.h.

◆ responseCode() [1/2]

HTTPBuilder & web::HTTPBuilder::responseCode ( int code,
std::string_view responseMessage )

◆ responseCode() [2/2]

HTTPBuilder & web::HTTPBuilder::responseCode ( ResponseCodes code)

Definition at line 164 of file HTTPBuilder.cpp.

◆ traceRequest()

HTTPBuilder & web::HTTPBuilder::traceRequest ( )

Set TRACE request.

Returns
Self

Definition at line 119 of file HTTPBuilder.cpp.

Friends And Related Symbol Documentation

◆ operator<<

HTTP_API std::ostream & operator<< ( std::ostream & outputStream,
const HTTPBuilder & builder )
friend

Set HTTP to output stream.

Parameters
outputStreamstd::ostream subclass instance
parserconst reference to HTTPBuilder instance
Returns
outputStream

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