Skip to content
Florian Nücke edited this page Dec 6, 2013 · 1 revision

This library wraps wireless modems' HTTP capability in a function that returns an iterator over the lines of the request result.

  • http.request(url: string[, data: string or table]): function
    Sends an HTTP request to the specified URL, with the specified POST data, if any. If no data is specified, a GET request will be made. The POST data can be in one of two formats: if it's a string, it will be sent as-is. If it's a table, it will be converted to a string by assuming that each key is the name of a POST variable, and it's associated value is the value for that variable. So, for example:
    http.request(url, {some = "variable", another = 1})
    Will send some=variable&another=1.
    The returned function is an iterator over the lines of the result, use it like so:
    for line in http.request(...) do stuff() end
    Important: you should not call os.sleep, event.pull or any other functions that directly or indirectly consume signals while iterating the result lines, since the lines of the response are one signal each (to avoid running out of memory for large results).

Clone this wiki locally