IHttpCompletionInfo::GetCompletionBytes Method
Collapse the table of content
Expand the table of content

IHttpCompletionInfo::GetCompletionBytes Method

IIS 7.0
 

Returns the number of bytes completed for an asynchronous operation.

virtual DWORD GetCompletionBytes(
   VOID
) const = 0;

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.

Example

The following code example demonstrates how to create an HTTP module that performs the following tasks:

  1. The module registers for the RQ_BEGIN_REQUEST and RQ_MAP_REQUEST_HANDLER notifications.

  2. The module creates a CHttpModule class that contains OnBeginRequest, OnMapRequestHandler, and OnAsyncCompletion methods.

  3. When a Web client requests a URL, IIS calls the module's OnBeginRequest method. This method performs the following tasks:

    1. Clears the existing response buffer and sets the MIME type for the response.

    2. Creates an example string and returns that to the Web client asynchronously.

    3. 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.

  4. IIS then calls the module's OnMapRequestHandler method. This method performs the following tasks:

    1. Flushes the current response buffer to the Web client.

    2. Tests for an error or asynchronous completion. If asynchronous completion is pending, the module returns a pending notification status to the pipeline.

  5. If asynchronous completion is required, IIS calls the module's OnAsyncCompletion method. This method performs the following tasks:

    1. 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.

    2. Creates strings that contain the completion information and writes the information as an event to the application log of the Event Viewer.

  6. The module removes the CHttpModule class from memory and then exits.

Your module must export the RegisterModule function. You can export this function by creating a module definition (.def) file for your project, or you can compile the module by using the /EXPORT:RegisterModule switch. For more information, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.

You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.

Requirements

Type

Description

Client

  • IIS 7.0 on Windows Vista

  • IIS 7.5 on Windows 7

  • IIS 8.0 on Windows 8

  • IIS 10.0 on Windows 10

Server

  • IIS 7.0 on Windows Server 2008

  • IIS 7.5 on Windows Server 2008 R2

  • IIS 8.0 on Windows Server 2012

  • IIS 8.5 on Windows Server 2012 R2

  • IIS 10.0 on Windows Server 2016 Technical Preview

Product

  • IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0

  • IIS Express 7.5, IIS Express 8.0, IIS Express 10.0

Header

Httpserv.h

Show:
© 2016 Microsoft