HttpReceiveRequestEntityBody function

The HttpReceiveRequestEntityBody function receives additional entity body data for a specified HTTP request.


ULONG HttpReceiveRequestEntityBody(
  _In_      HANDLE          ReqQueueHandle,
  _In_      HTTP_REQUEST_ID RequestId,
  _In_      ULONG           Flags,
  _Out_     PVOID           pBuffer,
  _In_      ULONG           BufferLength,
  _Out_opt_ PULONG          pBytesReceived,
  _In_opt_  LPOVERLAPPED    pOverlapped


ReqQueueHandle [in]

The handle to the request queue from which to retrieve the specified entity body data. A request queue is created and its handle returned by a call to the HttpCreateRequestQueue function.

Windows Server 2003 with SP1 and Windows XP with SP2:  The handle to the request queue is created by the HttpCreateHttpHandle function.

RequestId [in]

The identifier of the HTTP request that contains the retrieved entity body. This value is returned in the RequestId member of the HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. This value cannot be HTTP_NULL_ID.

Flags [in]

This parameter can be the following flag value.

Windows Server 2003 with SP1 and Windows XP with SP2:  This parameter is reserved and must be zero.


Specifies that the buffer will be filled with one or more entity bodies, unless there are no remaining entity bodies to copy.


pBuffer [out]

A pointer to a buffer that receives entity-body data.

BufferLength [in]

The size, in bytes, of the buffer pointed to by the pBuffer parameter.

pBytesReceived [out, optional]

Optional. A pointer to a variables that receives the size, in bytes, of the entity body data returned in the pBuffer buffer.

When making an asynchronous call using pOverlapped, set pBytesReceived to NULL. Otherwise, when pOverlapped is set to NULL, pBytesReceived must contain a valid memory address, and not be set to NULL.

pOverlapped [in, optional]

For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.

A synchronous call blocks until the entity-body data has been retrieved, whereas an asynchronous call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.

Return value

If the function succeeds, the return value is NO_ERROR.

If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready and is retrieved later through normal overlapped I/O completion mechanisms.

If the function fails, the return value is one of the following error codes.


One or more of the supplied parameters are in an unusable form.


The specified entity body has already been completely retrieved; in this case, the value pointed to by pBytesReceived is not meaningful, and pBuffer should not be examined.


The calling application did not call HttpInitialize before calling this function.


A system error code defined in WinError.h.



To retrieve an entire entity body, an application is expected to call HttpReceiveRequestEntityBody, passing in new buffers, until the function returns ERROR_HANDLE_EOF. As long as a buffer full of entity-body data is copied successfully and there is still more entity-body data waiting to be retrieved, the function returns NO_ERROR.


Minimum supported client

Windows Vista, Windows XP with SP2 [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]







See also

HTTP Server API Version 1.0 Functions
HTTP Server Sample Application