Attempt to fetch a webpage using the POST method, using the same arguments as http.request. This will return the response table or false, an error message and (sometimes) a handle with the failing response’s content (specifically, this is included when the actual request succeeded, but the server returned an erroneous HTTP code, e.g. 401: Unauthorized).
  • url : string
  • postData : string
  • headers? : table
  • binary? : boolean

Returns table response | boolean false, string error[, table response]
API http
Source CC:Tweaked (source)

The HTTP API assumes Unicode by default, meaning you may run into issues when fetching binary data. To avoid this, set binary to true. You will have to pass something to postData and headers to set the binary flag, e.g., "", nil, true).

ExampleDownloading a page
Requests a single page with some postdata and prints the contents.
-- Make a HTTP request
local request, err ="", "test=data&one=two")
if not request then error(err) end
-- Print the contents
request.close() -- Don't forget to close!
Output Prints test=data&one=two
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.