Module ctr.httpc

The httpc module.

Usage:

    local httpc = require("ctr.httpc")

Functions

context () Create a HTTP Context.

context object

:open (url[, method="GET"]) Open an url in the context.
:addRequestHeaderField (name, value) Add a field in the request header.
:beginRequest () Begin a request to get the content at the URL.
:getStatusCode () Return the status code returned by the request.
:getDownloadSize () Return the amount of data to download.
:downloadData () Download and return the data of the context.
:close () Close the context.
:addPostData (name, value) Add a POST form field to a HTTP context.
:getResponseHeader (name[, maximum=2048]) Get a header field from a response.
:addTrustedRootCA (DER) Add a trusted RootCA cert to a context.
:setSSLOptions (disableVerify[, tlsv10=false]) Set SSL options for a context.
addDefaultCert () Add all the default certificates to the context.


Functions

context ()
Create a HTTP Context.

Returns:

    context a new http context

context object

:open (url[, method="GET"])
Open an url in the context.

Parameters:

  • url string the url to open
  • method string method to use; can be "GET", "POST", "HEAD", "PUT" or "DELETE" (default "GET")

Returns:

    boolean true if everything went fine

Or

  1. boolean false in case of error
  2. integer error code
:addRequestHeaderField (name, value)
Add a field in the request header.

Parameters:

  • name string Name of the field
  • value string Value of the field

Returns:

    boolean true if everything went fine

Or

  1. boolean false in case of error
  2. integer error code
:beginRequest ()
Begin a request to get the content at the URL.

Returns:

    boolean true if everything went fine

Or

  1. boolean false in case of error
  2. integer error code
:getStatusCode ()
Return the status code returned by the request.

Returns:

    integer the status code

Or

  1. nil in case of error
  2. integer error code
:getDownloadSize ()
Return the amount of data to download.

Returns:

    number size in (bytes)
:downloadData ()
Download and return the data of the context.

Returns:

    string data

Or

  1. nil in case of error
  2. integer error code
:close ()
Close the context.
:addPostData (name, value)
Add a POST form field to a HTTP context.

Parameters:

  • name string name of the field
  • value string value of the field
:getResponseHeader (name[, maximum=2048])
Get a header field from a response.

Parameters:

  • name string name of the header field to get
  • maximum number size of the value to get (default 2048)

Returns:

    string field value
:addTrustedRootCA (DER)
Add a trusted RootCA cert to a context.

Parameters:

Returns:

    boolean true if everything went fine

Or

  1. boolean false in case of error
  2. integer error code
:setSSLOptions (disableVerify[, tlsv10=false])
Set SSL options for a context.

Parameters:

  • disableVerify boolean disable server certificate verification if true
  • tlsv10 boolean use TLS v1.0 if true (default false)
addDefaultCert ()
Add all the default certificates to the context.
generated by LDoc 1.4.3 Last updated 2017-06-05 14:35:27