Skip to main content

httpstream.closeasync(callback, timeout)

Closes an asynchronous HTTP stream

Availability

Agent

Parameters

Name Type Description
callback Function Optional handler function for streaming responses
timeout Float or integer Optional timeout in seconds

Returns

Nothing

Description

This method completes the HTTP streaming request and asynchronously waits for the server’s response. It should be called only when the entire request body has been sent. Other Squirrel code, including other event handlers, continue to run while the agent is waiting for the response. This is not the case during a call to httpstream.closesync(), which blocks until the response has been received.

If the optional timeout is not provided, httpstream.closeasync() defaults to a timeout of 600 seconds (ten minutes). To disable the timeout, set this parameter to the constant NO_TIMEOUT.

The function passed into the callback parameter is optional. If provided, it will be executed whenever there is more content being returned by the server, allowing Squirrel to handle large or streamed responses from the server. It is called with the following parameter of its own:

Parameter Type Description
content String The content from the stream

Any attempt to send data to a cancelled or closed stream, including one which has received an error from the server, will cause a Squirrel error.