Skip to main content

http.putstream(url, headers, callback)

Returns a new HTTP PUT stream request object

Availability

Agent

Parameters

Name Type Description
url String The URL to which the stream will be sent
headers Table A table of additional HTTP headers (may be empty)
callback Function A function that will be executed when the transfer completes either successfully or because of an error

Returns

An httpstream object

Description

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. If you know the size of the data to be sent, then you should use http.put() instead.

The returned httpstream object is primed to make an HTTP/1.1 PUT request to the URL specified by the url parameter. The URL must start with "http://" or "https://".

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 references a table with the following keys:

Key Type Description
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.