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.

nsITraceableChannel

这个接口用于允许拦截 HTTP 流量。It is implemented by nsIHttpChannel.
1.0
28
Introduced
Gecko 1.9.0.4
继承于: nsISupports 最后修改于Gecko 1.9.0.4

使用这个接口的典型方式如下:

之后,你的 nsIStreamListener 实现将会获取到响应数据(response data),并且能够传递数据到原始的 nsIStreamListener(可能会修改它)。

See nsITraceableChannel, Intercept HTTP Traffic for a more detailed description with code samples.

See Modify URL before loading page in firefox for an overview of how to modify a request before it is made.

Method overview

nsIStreamListener setNewListener(in nsIStreamListener aListener);

Methods

setNewListener()

用一个新的来替换该通道的当前监听器,返回先前分配给该通道的监听器。

nsIStreamListener setNewListener(
  in nsIStreamListener aListener
);
参数
aListener
An nsIStreamListener to be notified of events on the HTTP channel.
返回值

该通道的前一个监听器。Each listener call through to the previous listener for every call, in order to establish a call chain to allow all interested parties a chance to act on each event.

实现 nsIStreamListener

一个 nsIStreamListener 接口传递给 setNewListener() 需要实现下列的方法,这是通过调用(这些方法)来通知它在 HTTP stream 上发生的事件:

  • onStartRequest:一个 HTTP 请求开始。
  • onDataAvailable:数据到达 HTTP 通道(HTTP channel)。
  • onStopRequest:HTTP 请求结束。
Note: It is critical that you pass along requests to the previous listener as soon as possible -- especially for onStartRequest.

Channels may restrict when you may replace the listener. In particular, listeners typically should not be replaced after onStartRequest has been called.

文档标签和贡献者

 此页面的贡献者: ziyunfei, zbinlin
 最后编辑者: ziyunfei,