Returns a new HTTP POST stream request object
The URL to which the stream will be sent
A table of additional HTTP headers (may be empty)
A function that will be executed when the transfer completes either successfully or because of an error
This method creates an httpstream object that can be used to stream data to a specified server when the size of the content is not known ahead of time. For example, you may choose to use streaming when you need to send live data updates to a data-logging service — ie. the outbound equivalent to long polling. If you know the size of the data to be sent, then you should use http.post() instead.
The returned httpstream object is primed to make an HTTP/1.1 POST request to the URL specified by the url parameter. The URL must start with
The headers passed as a table into headers can be any supported by HTTP.
The function passed into callback will be invoked with a single parameter, response, which will reference a table with the following keys:
|statuscode||Integer||HTTP status code (or libcurl error code)|
|headers||Table||Squirrel table of returned HTTP headers|
|body||String||Returned HTTP body (if any)|
For the possible values of statuscode, see httprequest.sendasync().
Note Once the callback has been invoked, the httpstream object is no longer valid, and any further calls to its methods will result in Squirrel errors.
The agent code below uses http.poststream() to initiate a stream — in the function initiateStream() — which is then used to post dummy data — in streamData() — to the Plot.ly service.