Data Structures | Macros | Typedefs | Functions
http_client.h File Reference

HTTP client. More...

Data Structures

struct  vtm_http_client_req
 
struct  vtm_http_client_res
 

Macros

#define VTM_HTTP_CL_OPT_NO_CERT_CHECK   1
 
#define VTM_HTTP_CL_OPT_TIMEOUT   2
 

Typedefs

typedef struct vtm_http_client vtm_http_client
 

Functions

VTM_API vtm_http_client * vtm_http_client_new (void)
 
VTM_API void vtm_http_client_free (vtm_http_client *cl)
 
VTM_API int vtm_http_client_set_opt (vtm_http_client *cl, int opt, const void *val, size_t len)
 
VTM_API int vtm_http_client_request (vtm_http_client *cl, struct vtm_http_client_req *req, struct vtm_http_client_res *res)
 
VTM_API void vtm_http_client_res_release (struct vtm_http_client_res *res)
 

Macro Definition Documentation

#define VTM_HTTP_CL_OPT_NO_CERT_CHECK   1

expects bool

#define VTM_HTTP_CL_OPT_TIMEOUT   2

expects unsigned long, value is millisceonds

Function Documentation

VTM_API vtm_http_client* vtm_http_client_new ( void  )

Creates a new client.

Returns
the created client which can be used in the other functions
NULL if an error occured
VTM_API void vtm_http_client_free ( vtm_http_client *  cl)

Releases the client and all allocated resources.

After this call the client pointer is no longer valid.

Parameters
clthe client that should be released
VTM_API int vtm_http_client_set_opt ( vtm_http_client *  cl,
int  opt,
const void *  val,
size_t  len 
)

Sets one of the possible options.

The possible options are macros starting with VTM_HTTP_CL_OPT_.

Parameters
clthe client where the option should be set
optthe option that should be set
valpointer to new value of the option
lensize of the value
Returns
VTM_OK if the option was successfully set
VTM_E_NOT_SUPPORTED if the given option or the value format is not supported
VTM_ERROR if an error occured
VTM_API int vtm_http_client_request ( vtm_http_client *  cl,
struct vtm_http_client_req req,
struct vtm_http_client_res res 
)

Sends specified HTTP request and retrieves response.

This call blocks until the response was received or the timeout elapsed.

Parameters
clthe client that should make the request
reqthe request parameters
[out]resthe response is stored here
Returns
VTM_OK if the call succeeded and a response was received
VTM_E_IO_TIMEOUT if the timeout elapsed before the response was received
VTM_E_IO_UNKNOWN or VTM_ERROR if an error occured
VTM_API void vtm_http_client_res_release ( struct vtm_http_client_res res)

Releases all allocated resources of the given response.

Parameters
resthe response that should be released