PHttpRequest Class Reference

Detailed Description

The PHttpRequest class ease handling HTTP requests.

Definition at line 28 of file PHttpRequest.h.

#include <PHttpRequest.h>

Constructor & Destructor Documentation

◆ PHttpRequest() [1/2]

PHttpRequest::PHttpRequest ( const PString url)
explicit

Constructs a PHttpRequest with given URL.

Other options such as timeout, redirection follow-up, and https without certificate verification are set separately.

◆ PHttpRequest() [2/2]

PHttpRequest::PHttpRequest ( const PHttpRequest other)

Constructs a shared copy of other.

◆ ~PHttpRequest()

virtual PHttpRequest::~PHttpRequest ( )
virtual

Destroys this object.

Member Function Documentation

◆ FollowRedirections()

void PHttpRequest::FollowRedirections ( bool  redirections)

Enables HTTP redirection following, if this is not set and a redirection is necessary then a HTTP 302 will be received.

◆ Get()

PResult PHttpRequest::Get ( PHttpResponse response,
const PStringMap queries = PStringMap() 
) const

Makes a GET request to the URL provided via the constructor.

Optionally, query strings may be fed in a PMap. A PMap such as the one below,

PHttpRequest request("http://10.0.0.2/stream3"); PMap<PString, PString> queryStrings; queryStrings.Put("format", "mp4"); queryStrings.Put("resolution", "qcif"); ...

will make a GET request to http://10.0.0.2/stream3?format=mp4&resolution=qcif

The HTTP response will be returned in a PHttpResponse object.

Returns
PResult::C_OK on success, PResult::Error otherwise.

◆ Post()

PResult PHttpRequest::Post ( PHttpResponse response,
const PString data = PString::Empty() 
)

Makes a POST request to the URL provided via the constructor.

Optionally, data may be provided to be POSTed along.

The HTTP response will be returned in a PHttpResponse object.

Returns
PResult:C_OK on success, PResult::Error otherwise.

◆ SetCredentials()

void PHttpRequest::SetCredentials ( const PString username,
const PString password 
)

Sets username and password for the HTTP authentication.

HTTP authentication method is set by default to ANY, so all the available authentication methods will be tried until success.

◆ SetInsecure()

void PHttpRequest::SetInsecure ( bool  insecure)

Disables the certificate checking for an HTTPS connection.

◆ SetTimeout()

void PHttpRequest::SetTimeout ( papillon::uint32  timeoutMs)

Sets the timeout (in milliseconds) for the HTTP request to complete.

Note that this is not the connection timeout but the timeout for the entire process until an HTTP response is arrived to the user - hence including the connection timeout.