User Tools

Site Tools


DzHttpHelper

Convenience object for HTTP requests.

More...

Inherits :

Constructors

DAZ Script
DzHttpHelper ()

Methods

DAZ Script
voidabort ()
voiddoAsynchronousRequest ( ByteArray content=undefined )
ByteArraydoSynchronousRequest ( ByteArray content=undefined )
StringgetError ()
voidsetConnectionMode ( String mode )
voidsetContentType ( String type )
voidsetHeaderValues ( Array keys, Array values )
voidsetHost ( String host )
voidsetPath ( String path )
voidsetQueryString ( String query )
voidsetRequestMethod ( String method )

Signals

voidreceived ( ByteArray bytes )

Detailed Description

Provides a simple implementation of the HTTP protocol.

See Also:

Constructors


DzHttpHelper()

Constructor. Creates a new instance.

Methods


void : abort()

Aborts the current request and deletes all scheduled requests.


void : doAsynchronousRequest( ByteArray content=undefined )

Sends an asynchronous request to the server.

Parameter(s):

  • content - The content to send (if any).

Attention:

  • This function returns immediately, it does not wait for a response.

See Also:


ByteArray : doSynchronousRequest( ByteArray content=undefined )

Sends a synchronous request to the server.

Parameter(s):

  • content - The content to send (if any).

Return Value:

  • A byte array consisting of the response content.

Attention:

  • This function waits for a response.

See Also:


String : getError()

Return Value:

  • A human-readable description of the last error that occurred (if any), otherwise an empty string.

void : setConnectionMode( String mode )

Sets the HTTP connection mode used for connecting to the server.

Parameter(s):

  • mode - The connection mode to set - i.e., “http” or “https”.

void : setContentType( String type )

Sets the value of the special HTTP header content-type field.

Parameter(s):

  • type - The content-type to set - e.g., “application/json”.

void : setHeaderValues( Array keys, Array values )

Parameter(s):

  • keys - The keys in the http header.
  • values - The corresponding values for the keys.

Attention:

  • Keys and Values must be the same length

void : setHost( String host )

Sets the host for requests.

Parameter(s):


void : setPath( String path )

Sets the path portion of the URL.

Parameter(s):

  • path - The path to set - e.g., “/dazApi/slab/13176”.

void : setQueryString( String query )

Sets the query string (and optionally fragment) portion of the URL.

Parameter(s):

  • query - The query string (and optionally fragment) to set.

void : setRequestMethod( String method )

Sets the HTTP request method which describes the requests action.

Parameter(s):

  • method - The request method to set - e.g., “GET”, “POST”, “HEAD”.

Signals


void : received( ByteArray bytes )

Signature:“received(QByteArray)”

Emitted when new bytes are received.