Skip to main content

httpstream

Availability

Agent

Description

The HTTPStream class represents a single HTTP streaming request, ie. a request where the body is not known at the outset. A new httpstream object is returned from each call to http.poststream(), http.putstream() and http.requeststream()

An httpstream embodies a stream that will be sent by the agent. It is implemented using the “HTTP Transfer-Encoding: Chunked” protocol. This protocol is not available before HTTP 1.1, so a server that is based on HTTP 1.0 or earlier is likely to return status 500 (internal error) or some other error condition.

The body of the request can be sent incrementally and the connection will be kept open until a close method (httpstream.closeasync() or httpstream.closesync()) is called; the connection is cancelled; or an error takes place. The stream is not guaranteed to be divided into chunks corresponding exactly to httpstream.send() calls. For example, if you issue several such calls very quickly, they may be concatenated into a single chunk.

Rate-Limiting

The number of streaming requests you can make is rate-limited. Available request credits are shared among httprequest and httpstream. You have credit for a total of 40 requests of any type, ie. if you issue 20 httprequests you can only issue 20 httpstreams until your credits are replenished. As requests are issued they regenerate at the rate of two credits per second, up to the maximum of 40. This allows you to make 120 requests in 60 seconds, issuing up to 40 at any one time.

The rate-limiting mechanism will start counting an httpstream against the limit when the first send has been called.

  • You can find a list of HTTP request response codes with specific meanings for imp-enabled devices here.

Member Entities

The httpstream object has the following member methods: