Returns the number of bytes completed for an asynchronous operation.
This method takes no parameters.
A DWORD that contains the number of bytes.
The GetCompletionBytes method allows you to retrieve the number of bytes that were completed during an asynchronous operation. When an operation completes asynchronously, IIS creates an IHttpCompletionInfo interface and passes that interface to your module's CHttpModule::OnAsyncCompletion method to process the results of the asynchronous operation. You can then use GetCompletionBytes to retrieve the completed bytes for the asynchronous operation.
For example, if your module requested the IHttpRequest::ReadEntityBody method to complete asynchronously, GetCompletionBytes would return the number of bytes read. Similarly, if your module requested asynchronous completion of the IIHttpResponse::Flush method, GetCompletionBytes would return the number of bytes flushed to the client. In addition, GetCompletionBytes returns the number of bytes that you specify when you call the IHttpContext::PostCompletion method.
The following code example demonstrates how to create an HTTP module that performs the following tasks:
When a Web client requests a URL, IIS calls the module's OnBeginRequest method. This method performs the following tasks:
Clears the existing response buffer and sets the MIME type for the response.
Creates an example string and returns that to the Web client asynchronously.
Tests for an error or asynchronous completion. If asynchronous completion is pending, the module returns a pending notification status to the integrated request-processing pipeline.
IIS then calls the module's OnMapRequestHandler method. This method performs the following tasks:
Flushes the current response buffer to the Web client.
Tests for an error or asynchronous completion. If asynchronous completion is pending, the module returns a pending notification status to the pipeline.
If asynchronous completion is required, IIS calls the module's OnAsyncCompletion method. This method performs the following tasks:
Tests for a valid IHttpCompletionInfo interface. If a valid IHttpCompletionInfo interface was passed, the method calls the GetCompletionBytes and GetCompletionStatus methods, respectively, to retrieve the completed bytes and return the status for the asynchronous operation.
Creates strings that contain the completion information and writes the information as an event to the application log of the Event Viewer.
The module removes the CHttpModule class from memory and then exits.