tfHttpcUserSendRequestMethodLine
Table of Contents >> Application Reference >> Web Client
| #include <trsocket.h> |
| int tfHttpcUserSendRequestMethodLine | ( |
| ttHttpcUserConHandle conHandle, | |
| ttHttpUserVersion version, | |
| ttHttpUserMethod method, | |
| const char * pathPtr, | |
| int flags | |
| ); |
Function Description
Send a HTTP request method line to the HTTP server.
In blocking mode, the user will be blocked until the method line has been sent out completely or an error occurs.
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 method line has been sent out. If TM_EWOULDBLOCK is returned, the method line has been partially sent out.
When TM_EWOULDBLOCK is returned, user has two choices:
- Call this API again and again (polling mode) until it returns TM_ENOERROR indicating the request method line has 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
- version
- HTTP version. One of the following:
- TM_HTTP_VERSION_0_9
- TM_HTTP_VERSION_1_0
- TM_HTTP_VERSION_1_1
- method
- Request method. One of the following:
- TM_HTTP_METHOD_GET
- TM_HTTP_METHOD_HEAD
- TM_HTTP_METHOD_POST
- TM_HTTP_METHOD_PUT
- TM_HTTP_METHOD_DELETE
- TM_HTTP_METHOD_MPOST
- TM_HTTP_METHOD_NOTIFY
- TM_HTTP_METHOD_SUBSCRIBE
- TM_HTTP_METHOD_UNSUBSCRIBE
- pathPtr
- Pointer to the request path 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_EINVAL
- One of the parameters is invalid.
- TM_ENOTCONN
- Not connected
- TM_ESHUTDOWN
- The connection is being closed
- TM_EBADF
- The socket descriptor is invalid
- TM_ENOBUFS
- There was insufficient user memory available to complete the operation.
- TM_EWOULDBLOCK
- The socket is marked as non-blocking and the request has been partially sent out