tfHttpcUserGetResponseStatusLine
Table of Contents >> Application Reference >> Web Client
#include <trsocket.h> |
int tfHttpcUserGetResponseStatusLine | ( |
ttHttpcUserConHandle conHandle, | |
ttHttpUserVersion * versionPtr, | |
int * statusCodePtr, | |
char ** reasonPhrasePtr, | |
int timeOut, | |
int flags | |
); |
Function Description
Get the status line from the received HTTP response message.
In blocking mode, this API blocks until the status line has been received, the time out period has elapsed, or an error has occurred.
In non-blocking mode, this API gets what is on the socket and returns immediately. The user needs to check the return code for the receiving status. When TM_ENOERROR is returned, the status line has been received. When TM_EWOULDBLOCK is returned, the status line is only partially received.
When TM_EWOULDBLOCK is returned, the user has two choices:
- Call this API again and again until it returns TM_ENOERROR indicating the response status line has been received, 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_RECV_READY is notified, user may call this API again to receive the response.
Parameters
- conHandle
- User connection handle.
- versionPtr
- Pointer to a variable to receive the HTTP version (e.g. TM_HTTP_VERSION_1_1).
- statusCodePtr
- Pointer to a variable to receive the HTTP status code.
- reasonPhrasePtr
- Pointer to a variable to receive the pointer to HTTP reason phrase. The storage for the string is contained within and owned by the descriptor associated with conHandle.
- timeOut
- Receiving timeout period for blocking mode, in seconds. Specify -1 for infinite timeout; the caller will be blocked until the status line has been received or an error occurred.
- flags
- ORable flags:
- TM_BLOCKING_ON, blocking mode.
- TM_BLOCKING_OFF, non-blocking mode
Returns
- TM_ENOERROR
- The status line has been received successfully
- TM_ETIMEDOUT
- Used for blocking mode. The time out period has elapsed before the status line is received. User could choose call this API again or close the connection.
- TM_EWOULDBLOCK
- Used for non-blocking mode only. The status line hasnât been received yet. User should call this API again. User may wait for event TM_HTTPC_EVENT_RECV_READY before calling again.
- TM_EINVAL
- Invalid parameters
- TM_ENOTCONN
- Not connected.
- TM_EPERM
- The operation is not permitted
- TM_EFORMAT
- The response is in wrong format. User should close the connection.
- TM_ENOBUFF
- There is no enough memory