nsIHttpActivityObserver 编辑

netwerk/protocol/http/nsIHttpActivityObserver.idlScriptable This interface provides a way for http transport activities to be reported to observers. 1.0 66 Introduced Gecko 1.8 Inherits from: nsISupports Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

Method overview

void observeActivity(in nsISupports aHttpChannel, in PRUint32 aActivityType, in PRUint32 aActivitySubtype, in PRTime aTimestamp, in PRUint64 aExtraSizeData, in ACString aExtraStringData);

Attributes

AttributeTypeDescription
isActiveboolean

true when the interface is active and should observe HTTP activity, otherwise false. If this is false, the observeActivity() method should not be called. Read only.

Note: This attribute is present only for compatibility and should not be used.

Constants

Activity type constants

ConstantValueDescription
ACTIVITY_TYPE_SOCKET_TRANSPORT0x0001Socket transport activity has occurred.
ACTIVITY_TYPE_HTTP_TRANSACTION
0x0002HTTP transport activity has occurred.

Activity subtype constants

ConstantValueDescription
ACTIVITY_SUBTYPE_REQUEST_HEADER0x5001The HTTP request is about to be queued for sending. Observers can look at request headers in aExtraStringData
ACTIVITY_SUBTYPE_REQUEST_BODY_SENT0x5002The HTTP request's body has been sent.
ACTIVITY_SUBTYPE_RESPONSE_START0x5003The HTTP response has started to arrive.
ACTIVITY_SUBTYPE_RESPONSE_HEADER0x5004The HTTP response header has arrived.
ACTIVITY_SUBTYPE_RESPONSE_COMPLETE0x5005The complete HTTP response has been received.
ACTIVITY_SUBTYPE_TRANSACTION_CLOSE0x5006The HTTP transaction has been closed.

Methods

observeActivity()

Called when activity occurs on the HTTP transport. You should implement this method to perform whatever tasks you wish to perform when HTTP activity occurs.

void observeActivity(
  in nsISupports aHttpChannel,
  in PRUint32 aActivityType,
  in PRUint32 aActivitySubtype,
  in PRTime aTimestamp,
  in PRUint64 aExtraSizeData,
  in ACString aExtraStringData
);
Parameters
aHttpChannel
The nsIHttpChannel on which the activity occurred.
aActivityType
The type of activity that occurred; this will be one of the values specified in Activity type constants.
aActivitySubtype
The subtype that further narrows the type of activity that occurred. If the activity type is ACTIVITY_TYPE_SOCKET_TRANSPORT, this value will be one of the STATUS_* constants defined by nsISocketTransport. If the activity type is ACTIVITY_TYPE_HTTP_TRANSACTION, this will be one of the constants specified in Activity subtype constants above.
aTimestamp
The time at which the activity occurred, specified as microseconds elapsed since the epoch of midnight on January 1, 1970.
aExtraSizeData
Any additional size data available with this activity. See Interpreting activity data below.
aExtraStringData
Any additional string data available with this activity. See Interpreting activity data below.

Interpreting activity data

Depending on the values of the aActivityType and aActivitySubtype fields, the aExtraSizeData and aExtraStringData parameters take on different meanings.

Socket transport activity

When the activity type is ACTIVITY_TYPE_SOCKET_TRANSPORT and the subtype is STATUS_SENDING_TO, the aExtraSizeData parameter contains the number of bytes sent. Because a single HTTP transaction may consist of multiple chunks of data transmitted through separate socket writes, each socket activity notification will only reflect the number of bytes transmitted in that chunk.

HTTP transaction activity

For activity notifications of type ACTIVITY_TYPE_HTTP_TRANSACTION, there are three activities that include extra data:

ACTIVITY_SUBTYPE_REQUEST_HEADER
aExtraStringData contains the text of the header.
ACTIVITY_SUBTYPE_RESPONSE_HEADER
aExtraStringData contains the text of the response header.
ACTIVITY_SUBTYPE_RESPONSE_COMPLETE
aExtraSizeData contains the total number of bytes received.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:79 次

字数:8023

最后编辑:6年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文