HttpWriteRequestData

Sends the data portion of an HTTP request.

Syntax

    #include <httpexp.h>
    #include <httpclnt.h> 
     
    int HttpWriteRequestData (
       HINTERNET   hndl,
       void       *pDataBuffer,
       UINT32     *pDataBufferLen,
       void       *pContext,
       void      (*pCallBackRoutine)(
                  void       *pContext,
                  HINTERNET   hndl,
                  int         returnCode,
                  void       *reserved)
       );
    

Parameters

hndl
(IN) Specifies the connection handle returned from HttpConnect.
pDataBuffer
(IN) Points to the data for the body of the request.
pDataBufferLen
(IN) Points to the length of the data pointed to by the pDataBuffer parameter.
pContext
(IN) Points to optional context data, which is passed to your callback function. For a synchronous request, set it to NULL.
pCallBackRoutine
(IN) Points to the callback function that is called when an asynchronous request returns. For a synchronous request, set it to NULL.

The callback function is passed the following parameters:

  • pContext—Points to any optional context data that you passed in when you called HttpWriteRequestData.
  • hndl—Specifies the HTTP connection handle received for this request.
  • returnCode—Specifies the error status for the HttpWriteRequestData call. Zero indicates no errors; nonzero indicates an error. See Return Values for possible error codes.
  • reserved—Reserved for future use. Currently returns NULL.

Return Values

If successful, returns 0. For an asynchronous request, success means that the parameters are valid and the data has been sent. For a synchronous request, success means that the data has been sent and the reply has been received.

On failure, returns a nonzero error code.

Decimal

Name

Description

168

ERR_ACCESS_DENIED

The handle is invalid, the call was made out of sequence, or the call was made when a callback on the handle is pending.

255

ERR_BAD_PARAMETER

An invalid parameter was passed to the function.

>10000

WSA...

WinSock errors.

Remarks

The HttpWriteRequestData function can be called as many times as necessary to send all the data.

The function can be used synchronously or asynchronously. In synchronous mode, the function blocks until the send is completed and the status is returned. To use this mode, set the pContext and pCallBackRoutine parameters to NULL.

In asynchronous mode, the initial status returns immediately. If it is zero, the data has been sent and your callback function is called when the data has been written. If the initial status is nonzero, an error has occurred, the data is not sent, and your callback function is never called.

See Also