Moai SDK  2.0
MOAIHttpTaskBase Class Reference
+ Inheritance diagram for MOAIHttpTaskBase:

Function List

getProgress
 
getResponseCode
 
getResponseHeader
 
getSize
 
getString
 
httpGet
 
httpPost
 
isBusy
 
parseXml
 
performAsync
 
performSync
 
setBody
 
setCallback
 
setCookieSrc
 
setCookieDst
 
setFailOnError
 
setFollowRedirects
 
setHeader
 
setSSLOptions
 
setStream
 
setTimeout
 
setUrl
 
setUserAgent
 
setVerb
 
setVerbose
 

Detailed Description

Constants
MOAIHttpTaskBase.HTTP_GET
MOAIHttpTaskBase.HTTP_HEAD
MOAIHttpTaskBase.HTTP_POST
MOAIHttpTaskBase.HTTP_PUT
MOAIHttpTaskBase.HTTP_DELETE

Function Documentation

getProgress

Returns the progress of the download.


function getProgress ( MOAIHttpTaskBase self )

Parameters
MOAIHttpTaskBaseself
Returns
number progress
getResponseCode

Returns the response code returned by the server after a httpPost or httpGet call.


function getResponseCode ( MOAIHttpTaskBase self )

Parameters
MOAIHttpTaskBaseself
Returns
number code
getResponseHeader

Returns the response header given its name, or nil if it wasn't provided by the server. Header names are case-insensitive and if multiple responses are given, they will be concatenated with a comma separating the values.


function getResponseHeader ( MOAIHttpTaskBase self, string header )

Parameters
MOAIHttpTaskBaseself
stringheader The name of the header to return (case-insensitive).
Returns
string response
getSize

Returns the size of the string obtained from a httpPost or httpGet call.


function getSize ( MOAIHttpTaskBase self )

Parameters
MOAIHttpTaskBaseself
Returns
number size
getString

Returns the text obtained from a httpPost or httpGet call.


function getString ( MOAIHttpTaskBase self )

Parameters
MOAIHttpTaskBaseself
Returns
string text
httpGet

Sends an API call to the server for downloading data. The callback function (from setCallback) will run when the call is complete, i.e. this action is asynchronous and returns almost instantly.


function httpGet ( MOAIHttpTaskBase self, string url [, string useragent, boolean verbose, boolean blocking ] )

Parameters
MOAIHttpTaskBaseself
stringurl The URL on which to perform the GET request.
stringuseragent Optional. Default value is "Moai SDK beta; support
booleanverbose Optional.
booleanblocking Optional. Synchronous operation; block execution until complete. Default value is false.
Returns
nil
httpPost

Sends an API call to the server for downloading data. The callback function (from setCallback) will run when the call is complete, i.e. this action is asynchronous and returns almost instantly.


function httpPost ( MOAIHttpTaskBase self, string url [, string data, string useragent, boolean verbose, boolean blocking ] )

Parameters
MOAIHttpTaskBaseself
stringurl The URL on which to perform the GET request.
stringdata Optional. The string containing text to send as POST data.
stringuseragent Optional. Default value is "Moai SDK beta; support
booleanverbose Optional.
booleanblocking Optional. Synchronous operation; block execution until complete. Default value is false.
Returns
nil
Note

function httpPost ( MOAIHttpTaskBase self, string url [, MOAIDataBuffer data, string useragent, boolean verbose, boolean blocking ] )

Parameters
MOAIHttpTaskBaseself
stringurl The URL on which to perform the GET request.
MOAIDataBufferdata Optional. A MOAIDataBuffer object to send as POST data.
stringuseragent Optional.
booleanverbose Optional.
booleanblocking Optional. Synchronous operation; block execution until complete. Default value is false.
Returns
nil
Note
isBusy

Returns whether or not the task is busy.


function isBusy ( MOAIHttpTaskBase self )

Parameters
MOAIHttpTaskBaseself
Returns
boolean busy
parseXml

Parses the text data returned from a httpGet or httpPost operation as XML and then returns a MOAIXmlParser with the XML content initialized.


function parseXml ( MOAIHttpTaskBase self )

Parameters
MOAIHttpTaskBaseself
Returns
MOAIXmlParser parser
performAsync

Perform the HTTP task asynchronously.


function performAsync ( MOAIHttpTaskBase self )

Parameters
MOAIHttpTaskBaseself
Returns
nil
performSync

Perform the HTTP task synchronously (blocking).


function performSync ( MOAIHttpTaskBase self )

Parameters
MOAIHttpTaskBaseself
Returns
nil
setBody

Sets the body for a POST or PUT.


function setBody ( MOAIHttpTaskBase self [, string data ] )

Parameters
MOAIHttpTaskBaseself
stringdata Optional. The string containing text to send as POST data.
Returns
nil
Note

function setBody ( MOAIHttpTaskBase self [, MOAIDataBuffer data ] )

Parameters
MOAIHttpTaskBaseself
MOAIDataBufferdata Optional. A MOAIDataBuffer object to send as POST data.
Returns
nil
Note
setCallback

Sets the callback function used when a request is complete.


function setCallback ( MOAIHttpTaskBase self, function callback )

Parameters
MOAIHttpTaskBaseself
functioncallback The function to execute when the HTTP request is complete. The MOAIHttpTaskBase is passed as the first argument.
Returns
nil
setCookieDst

Sets the file to save the cookies for this HTTP request.


function setCookieDst ( MOAIHttpTaskBase self, string filename )

Parameters
MOAIHttpTaskBaseself
stringfilename name and path of the file to save the cookies to
Returns
nil
setCookieSrc

Sets the file to read the cookies for this HTTP request.


function setCookieSrc ( MOAIHttpTaskBase self, string filename )

Parameters
MOAIHttpTaskBaseself
stringfilename name and path of the file to read the cookies from
Returns
nil
setFailOnError

Sets whether or not curl calls will fail if the HTTP status code is above 400.


function setFailOnError ( MOAIHttpTaskBase self, boolean enable )

Parameters
MOAIHttpTaskBaseself
booleanenable
Returns
nil
setFollowRedirects

Sets whether or not curl should follow HTTP header redirects.


function setFollowRedirects ( MOAIHttpTaskBase self, boolean follow )

Parameters
MOAIHttpTaskBaseself
booleanfollow
Returns
nil
setHeader

Sets a custom header field. May be used to override default headers.


function setHeader ( MOAIHttpTaskBase self, string key [, string value ] )

Parameters
MOAIHttpTaskBaseself
stringkey
stringvalue Optional. Default is "".
Returns
nil
setSSLOptions

SSL options for peer verification.


function setSSLOptions ( MOAIHttpTaskBase self, boolean verifyPeer, boolean verifyHost, string path )

Parameters
MOAIHttpTaskBaseself
booleanverifyPeer
booleanverifyHost
stringpath to ca-cert bundle (.crt)
Returns
nil
setStream

Sets a custom stream to read data into.


function setStream ( MOAIHttpTaskBase self, MOAIStream stream )

Parameters
MOAIHttpTaskBaseself
MOAIStreamstream
Returns
nil
setTimeout

Sets the timeout for the task.


function setTimeout ( MOAIHttpTaskBase self, number timeout )

Parameters
MOAIHttpTaskBaseself
numbertimeout
Returns
nil
setUrl

Sets the URL for the task.


function setUrl ( MOAIHttpTaskBase self, string url )

Parameters
MOAIHttpTaskBaseself
stringurl
Returns
nil
setUserAgent

Sets the 'useragent' header for the task.


function setUserAgent ( MOAIHttpTaskBase self [, string useragent ] )

Parameters
MOAIHttpTaskBaseself
stringuseragent Optional. Default value is "Moai SDK beta; support
Returns
nil
setVerb

Sets the HTTP verb.


function setVerb ( MOAIHttpTaskBase self, number verb )

Parameters
MOAIHttpTaskBaseself
numberverb One of MOAIHttpTaskBase.HTTP_GET, MOAIHttpTaskBase.HTTP_HEAD, MOAIHttpTaskBase.HTTP_POST, MOAIHttpTaskBase.HTTP_PUT, MOAIHttpTaskBase.HTTP_DELETE
Returns
nil
setVerbose

Sets the task implementation to print out debug information (if any).


function setVerbose ( MOAIHttpTaskBase self [, boolean verbose ] )

Parameters
MOAIHttpTaskBaseself
booleanverbose Optional. Default value is false.
Returns
nil