Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IXMLHTTPRequest2Callback::OnDataAvailable method

Occurs when a client receives part of the HTTP response data from the server.


HRESULT OnDataAvailable(
  [in, optional] IXMLHTTPRequest2  *pXHR,
  [in, optional] ISequentialStream *pResponseStream


pXHR [in, optional]

The initial HTTP request.

pResponseStream [in, optional]

The response stream being received. The client can call ISequentialStream::Read to begin processing the data, or it can wait until it has received the complete response. This response stream is wrapped in a stream synchronization object that prevents concurrent read and write operations, so the application does not need to implement custom synchronization.

Return value

Returns S_OK on success.

Note  This callback function must not throw exceptions.


When this callback function returns the application can begin processing data from the HTTP response, even if it has not yet received the entire response. However, receiving is suspended for the request until this callback function returns. Additionally, this callback can be invoked multiple times during a single request.

This callback function must not block and should not be made to perform resource intensive operations such as UI updates.

Custom streams receive a call to ISequentialStream::Write before OnDataAvailable is fired. The client can process data directly from the Write call instead of calling ISequentialStream::Read on the custom stream, and it can rely on the Write call to indicate that new data is available.


Minimum supported client

Windows 8 [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2012 [desktop apps | Windows Store apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]


MSXML 6.0 and later





See also

ISequentialStream Interface



© 2018 Microsoft