Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 3.92 KB

File metadata and controls

64 lines (48 loc) · 3.92 KB
title IHttpResponse::WriteEntityChunkByReference Method
description Learn how the IHttpResponse::WriteEntityChunkByReference method inserts or appends an HTTP_DATA_CHUNK structure into the response body.
ms.date 10/07/2016
ms.assetid 8cc3aefe-5f9e-9ae3-2e8a-b033aff39687

IHttpResponse::WriteEntityChunkByReference Method

Inserts or appends an HTTP_DATA_CHUNK structure into the response body.

Syntax

HRESULT WriteEntityChunkByReference(  
   IN HTTP_DATA_CHUNK* pDataChunk,  
   IN LONG lInsertPosition = -1  
)  

Parameters

pDataChunk
[IN] A pointer to an HTTP_DATA_CHUNK structure.

lInsertPosition
[IN] A LONG value that specifies whether to insert or append the chunk.

Return Value

An HRESULT. Possible values include, but are not limited to, those in the following table.

Value Description
S_OK Indicates that the operation was successful.
ERROR_INVALID_PARAMETER Indicates that the parameter is not valid (for example, the HTTP_DATA_CHUNK pointer is set to NULL).
ERROR_NOT_ENOUGH_MEMORY Indicates that there is insufficient memory to perform the operation.
ERROR_ARITHMETIC_OVERFLOW Indicates that more than 65535 chunks have been added to the response.

Remarks

The WriteEntityChunkByReference method inserts or appends an HTTP_DATA_CHUNK structure into the response buffer depending on the value of the lInsertPosition parameter.

  • If lInsertPosition is 0, the data will be inserted before the existing response data.

  • If lInsertPosition is -1, the data will be appended after the last chunk of existing response data.

    The WriteEntityChunkByReference method inserts a reference to the original data chunk, instead of a copy, into the response buffer. Therefore, the memory allocated for pDataChunk->FromMemory.pBuffer must persist for the duration of your response processing. Using local or stack memory results in undefined behavior.

    A maximum of 65535 (64 KB minus 1) chunks can be written to a request.

Example

The following example demonstrates how to use the WriteEntityChunkByReference method to insert data into the response. It also demonstrates how to use the lInsertPosition parameter to insert or append data chunks.

[!code-cppIHttpResponseWriteEntityChunkByReference#1]
[!code-cppIHttpResponseWriteEntityChunkByReference#2]

Requirements

Type Description
Client - IIS 7.0 on [!INCLUDEwinvista]
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on [!INCLUDEwinsrv2008]
- 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
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100]
Header Httpserv.h

See Also

IHttpResponse Interface
IHttpResponse::WriteEntityChunks Method