Skip to main content

http.requeststream(verb, url, headers, callback)

Returns a new HTTP stream request object

Availability

Agent

Parameters

Name Type Description
verb String The HTTP method required (eg. OPTIONS)
url String The URL to which the stream will be sent
headers Table A table of additional HTTP headers
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. The most common HTTP streaming request methods are provided by the imp API methods http.poststream() and http.putstream(), but you can use http.requeststream() if you need an HTTP method other than POST or PUT.

The returned httpstream object is primed to make a request of the type specified using the verb parameter, 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.