HCHttpCallRequestBodyReadFunction
An application-defined callback that an HTTP call invokes to read the request body. Register it with HCHttpCallRequestSetRequestBodyReadFunction.Syntax
Parameters
call   _In_Type: HCCallHandle The handle of the HTTP call. offset   _In_
Type: size_t The offset from the beginning of the request body at which to start reading. bytesAvailable   _In_
Type: size_t The maximum number of bytes that you can write to destination. context   _In_opt_
Type: void* The context that you passed to HCHttpCallRequestSetRequestBodyReadFunction. destination   _Out_writes_bytes_to_(bytesAvailable, *bytesWritten)
Type: uint8_t* The buffer that receives the request body data. bytesWritten   _Out_
Type: size_t* Receives the number of bytes that you actually wrote to destination.
Return value
Type: HRESULT Result code for this callback. Possible values areS_OK, E_INVALIDARG, or E_FAIL.
Remarks
libHttpClient calls this callback on an unspecified background thread that depends on the platform. Make any access to context or other shared state thread-safe. libHttpClient can call the callback more than once for a request attempt. Within an attempt, offset advances by the number of bytes that you wrote in earlier calls. If libHttpClient retries the call, a new attempt can start again at offset 0. If retries are allowed, your callback must be able to supply the body again from the beginning. To turn off retries, call HCHttpCallRequestSetRetryAllowed. On the built-in WinHTTP provider, a failure HRESULT from this callback ends the current attempt and is recorded as the call’s network error. Normal retry policy can start another attempt. After final completion, inspect HCHttpCallResponseGetNetworkErrorCode. To report upload progress in units other than the bytes sent (for example, the uncompressed bytes that your callback consumes), call HCHttpCallRequestSetDynamicSize with the total before you call HCHttpCallPerformAsync, and report increments with HCHttpCallRequestAddDynamicBytesWritten. You must know that total before the call starts. The bodySize that you pass to HCHttpCallRequestSetRequestBodyReadFunction must still be the exact number of bytes to send. The dynamic byte count isn’t reset if libHttpClient retries the call.Requirements
Header: httpClient.h Library: libHttpClient.lib Supported platforms: Windows, XBOX One family consoles and XBOX Series consolesSee also
httpClientHCHttpCallRequestSetRequestBodyReadFunction
HCHttpCallRequestSetDynamicSize
