Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIStreamListener

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

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.

文档标签和贡献者

 此页面的贡献者: Sheppy, trevorh, Smi, sathi, rufus
 最后编辑者: Sheppy,