tfHttpcUserSendRequestHeaders
Table of Contents >> Application Reference >> Web Client
| #include <trsocket.h> |
| int tfHttpcUserSendRequestHeaders | ( |
| ttHttpcUserConHandle conHandle, | |
| int * headerCountPtr, | |
| ttHttpUserHeaderType headerTypes[], | |
| const char * headerValues[], | |
| int flags | |
| ); |
Function Description
Send one or more HTTP headers to the HTTP server.
In blocking mode, the user will be blocked until the specific headers have been sent out completely.
In non-blocking mode, this API will only send what the socket send queue allows and returns immediately. User needs to check the return code for the sending status. If TM_ENOERROR is returned, the headers have been sent out. If TM_EWOULDBLOCK is returned, no headers or only some of the headers have been sent out. In such case, user should call this function again with the headers that havenât been sent out.
When TM_EWOULDBLOCK is returned, user has two choices:
- Call this API again and again until it returns TM_ENOERROR indicating the request headers have been sent out completely, or until an error occurs.
- Call tfHttpcUserExecute() periodically and wait for the event handler to be notified. This requires a non-NULL event handler to be passed to tfHttpcUserOpen(). When TM_HTTPC_EVENT_SEND_READY is notified, user may call this API again to send the rest of the request.
Parameters
- conHandle
- User connection handle
- headerCountPtr
- Points to the number of the HTTP headers in the headerTypes and headerValues array. The input value indicates the number of headers to be sent, when this API returns, the output value is updated to be the number of headers sent out.
- headerTypes[]
- Array of HTTP header types
- headerValues[]
- Array of HTTP header values as null terminated string
- flags
- ORable flags:
- TM_BLOCKING_ON, blocking mode.
- TM_BLOCKING_OFF, non-blocking mode
- TM_HTTPC_FLAG_END, set to indicate the end of the request
Returns
- TM_ENOERROR
- Successful
- TM_EWOULDBLOCK
- The socket is marked as non-blocking and only some of the headers have been sent out
- TM_EINVAL
- One of the parameters is invalid.
- TM_ENOTCONN
- Not connected
- TM_ESHUTDOWN
- The connection is being closed
- TM_EPERM
- The operation is not permitted
- TM_EBADF
- The socket descriptor is invalid