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

Attribute Type Description
isActive boolean

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

Constant Value Description
ACTIVITY_TYPE_SOCKET_TRANSPORT 0x0001 Socket transport activity has occurred.
ACTIVITY_TYPE_HTTP_TRANSACTION
0x0002 HTTP transport activity has occurred.

Activity subtype constants

Constant Value Description
ACTIVITY_SUBTYPE_REQUEST_HEADER 0x5001 The HTTP request is about to be queued for sending. Observers can look at request headers in aExtraStringData
ACTIVITY_SUBTYPE_REQUEST_BODY_SENT 0x5002 The HTTP request's body has been sent.
ACTIVITY_SUBTYPE_RESPONSE_START 0x5003 The HTTP response has started to arrive.
ACTIVITY_SUBTYPE_RESPONSE_HEADER 0x5004 The HTTP response header has arrived.
ACTIVITY_SUBTYPE_RESPONSE_COMPLETE 0x5005 The complete HTTP response has been received.
ACTIVITY_SUBTYPE_TRANSACTION_CLOSE 0x5006 The 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