netwerk/base/public/nsIStreamListener.idlScriptable
This interface is used to listen to data being received on a stream.
Inherits from: nsIRequestObserver Last changed in Gecko 1.0

Classes which want to consume data from a nsIChannel need to implement this interface. nsIRequestObserver contains two methods. So, in all the three methods - onDataAvailable(), nsIRequestObserver.onStartRequest() and nsIRequestObserver.onStopRequest() have to be implemented.

Method overview

void onDataAvailable(in nsIRequest aRequest, in nsISupports aContext, in nsIInputStream aInputStream, in unsigned long aOffset, in unsigned long aCount);

Methods

onDataAvailable()

This method is called when the next chunk of data for the ongoing request may be read without blocking the calling thread. The data can be read from the nsIInputStream object passed as the argument to this method.

Note: Your implementation of this method must read exactly aCount bytes of data before returning.

void onDataAvailable(
  in nsIRequest aRequest,
  in nsISupports aContext,
  in nsIInputStream aInputStream,
  in unsigned long aOffset,
  in unsigned long aCount
);
Parameters
aRequest
An nsIRequest indicating the source of the data.
aContext
A user-defined context value.
aInputStream
An nsIInputStream from which the data is to be read.
aOffset
Number of bytes that were sent in previous onDataAvailable() calls for this request. In other words, the sum of all previous count parameters. If that number is greater than or equal to 2^32, this parameter will be PR_UINT32_MAX (2^32 - 1).
aCount
The number of bytes available for reading. You must read all of these bytes before returning to the caller.

Note: Throwing an exception will cancel the request.