Murl Engine API  Version 2018.3
Murl::IUrlRequest Interface Referenceabstract

The url request interface. More...

#include <murl_i_url_request.h>

Detailed Description

The url request interface.

The IUrlRequest object can be created by the IWebControl object.

Inherited by Murl::Platform::Android::UrlRequest, Murl::Platform::Emscripten::UrlRequest, Murl::Platform::Foundation::UrlRequest, and Murl::Platform::Win32::UrlRequest.

Public Member Functions

virtual Bool SetHeaders (const Map< String, String > &headers)=0
 Define custom HTTP headers for the request. More...
 
virtual Bool ClearHeaders ()=0
 Clear any custom HTTP headers for the request. More...
 
virtual Bool SendGet (const String &url, Double timeout=60)=0
 Send a url-request with http method GET. More...
 
virtual Bool SendPost (const String &url, const Data &body, const String &contentType, Double timeout=60)=0
 Send a url-request with http method POST. More...
 
virtual const Map< String, String > & GetHeaders () const =0
 Get the custom HTTP headers defined for this request. More...
 
virtual const StringGetUrlString () const =0
 Get the url-request string. More...
 
virtual const DataGetResponseData () const =0
 Get the url-request response data. More...
 
virtual const Map< String, String > & GetResponseHeaders () const =0
 Get the HTTP headers received with this URL request's response. More...
 
virtual UInt64 GetCurrentDataSize () const =0
 Get the current response data size. More...
 
virtual Bool ReleaseData ()=0
 Release the response data. More...
 
virtual Bool IsPending () const =0
 Check if the url-request is pending. More...
 
virtual Bool WasFinished () const =0
 Check if the url-request was finished in the most recent tick. More...
 
virtual Bool WasRejected () const =0
 Check if the url-request was rejected in the most recent tick. More...
 

Member Function Documentation

◆ SetHeaders()

virtual Bool Murl::IUrlRequest::SetHeaders ( const Map< String, String > &  headers)
pure virtual

Define custom HTTP headers for the request.

This method can be used to define any number of custom HTTP headers sent with the URL request, given as a map containing string key/value pairs for the header names and values, respectively. Note: When using a POST request, the given headers should not include the "Content-Type" and "Content-Length" headers, as they are automatically added during SendPost().

Parameters
headersThe map of header key/value pairs.
Returns
true if successful.

◆ ClearHeaders()

virtual Bool Murl::IUrlRequest::ClearHeaders ( )
pure virtual

Clear any custom HTTP headers for the request.

Returns
true if successful.

◆ SendGet()

virtual Bool Murl::IUrlRequest::SendGet ( const String url,
Double  timeout = 60 
)
pure virtual

Send a url-request with http method GET.

When posting a url-request the IsPending() state is true. If the url-request was successful the WasFinished() state is true and the response data can be accessed by GetResponseData().

Parameters
urlThe url string to send to.
timeoutThe request timeout in seconds.
Returns
true if successful.

◆ SendPost()

virtual Bool Murl::IUrlRequest::SendPost ( const String url,
const Data body,
const String contentType,
Double  timeout = 60 
)
pure virtual

Send a url-request with http method POST.

When posting a url-request the IsPending() state is true. If the url-request was successful the WasFinished() state is true and the response data can be accessed by GetResponseData().
If the url is redirected, the POST is cancelled and WasRejected() state is true.

Parameters
urlThe url string to send to.
bodyThe body data to send.
contentTypeThe string for the "Content-Type" http header field.
timeoutThe request timeout in seconds.
Returns
true if successful.

◆ GetHeaders()

virtual const Map<String, String>& Murl::IUrlRequest::GetHeaders ( ) const
pure virtual

Get the custom HTTP headers defined for this request.

Returns
The map of header key/value pairs.

◆ GetUrlString()

virtual const String& Murl::IUrlRequest::GetUrlString ( ) const
pure virtual

Get the url-request string.

Returns
The url which was passed to SendGet() or SendPost().

◆ GetResponseData()

virtual const Data& Murl::IUrlRequest::GetResponseData ( ) const
pure virtual

Get the url-request response data.

The data is available if WasFinished() returns true.

Returns
The url-request response data.

◆ GetResponseHeaders()

virtual const Map<String, String>& Murl::IUrlRequest::GetResponseHeaders ( ) const
pure virtual

Get the HTTP headers received with this URL request's response.

The headers are available if WasFinished() returns true.

Returns
The map of header key/value pairs.

◆ GetCurrentDataSize()

virtual UInt64 Murl::IUrlRequest::GetCurrentDataSize ( ) const
pure virtual

Get the current response data size.

The size is updated while receiving data asynchronous.

Returns
The current response data byte size.

◆ ReleaseData()

virtual Bool Murl::IUrlRequest::ReleaseData ( )
pure virtual

Release the response data.

Releasing the data can be performed only if the url-request is not pending.

Returns
true if successful.

◆ IsPending()

virtual Bool Murl::IUrlRequest::IsPending ( ) const
pure virtual

Check if the url-request is pending.

Returns
true if the url-request is pending.

◆ WasFinished()

virtual Bool Murl::IUrlRequest::WasFinished ( ) const
pure virtual

Check if the url-request was finished in the most recent tick.

Returns
true if the url-request was finished in the most recent tick.

◆ WasRejected()

virtual Bool Murl::IUrlRequest::WasRejected ( ) const
pure virtual

Check if the url-request was rejected in the most recent tick.

Returns
true if the url-request was rejected in the most recent tick.

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