XROAD
http_client.h File Reference
#include <string.h>
#include <common/xroad_string.h>
#include <common/xroad_xml.h>
#include <common/xroad_map.h>
#include <common/xroad_list.h>
Include dependency graph for http_client.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  http_client_callback_t
 

Typedefs

typedef struct http_client_s http_client_t
 
typedef struct http_request_s http_request_t
 
typedef int64_t http_req_id_t
 

Enumerations

enum  http_verb_t { http_verb_get = 1 , http_verb_post = 2 , http_verb_put = 3 , http_verb_delete = 4 }
 

Functions

xroad_str_t http_verb_to_str (http_verb_t verb)
 
http_client_t * http_client_create (xroad_xml_tag_t cfg)
 
xroad_errno_t http_client_reconfig (http_client_t *c, xroad_xml_tag_t cfg)
 
void http_client_destroy (http_client_t *c)
 
http_req_id_t http_client_perform (http_client_t *c, http_verb_t verb, xroad_str_t path, xroad_list_t *headers, http_client_callback_t cback, const void *data, size_t len)
 
void http_client_cancel_request (http_req_id_t req)
 
xroad_str_t http_client_escape (xroad_str_t str)
 

Detailed Description

Function Documentation

◆ http_client_cancel_request()

void http_client_cancel_request ( http_req_id_t  req)

cancel http request

Parameters
[in]req- request to cancel

◆ http_client_create()

http_client_t* http_client_create ( xroad_xml_tag_t  cfg)

create http client

Parameters
[in]cfg- client configuration
Returns
new http client instance, NULL - in case of error

◆ http_client_destroy()

void http_client_destroy ( http_client_t *  c)

destroy http client and free all resources

Parameters
[in]c- http client to destroy

◆ http_client_escape()

xroad_str_t http_client_escape ( xroad_str_t  str)

escate string with urlencode

Parameters
[in]str- string to encode
Returns
url encoded string. must be freed with xroad_str_free

◆ http_client_perform()

http_req_id_t http_client_perform ( http_client_t *  c,
http_verb_t  verb,
xroad_str_t  path,
xroad_list_t headers,
http_client_callback_t  cback,
const void *  data,
size_t  len 
)

perform a http request

Parameters
[in]c- http client instance
[in]verb- request type (GET, POST, PUT, DELETE)
[in]path- request URL
[in]headers- options request headers
[in]cback- request callback
[in]data- POST body
[in]len- POST body len
Returns
request id > 0 - successful, < 0 - xroad_errno_t

◆ http_client_reconfig()

xroad_errno_t http_client_reconfig ( http_client_t *  c,
xroad_xml_tag_t  cfg 
)

reconfig http client

Parameters
[in]c- http client to configure
[in]cfg- new configuration instance
Returns
XROAD_OK

◆ http_verb_to_str()

xroad_str_t http_verb_to_str ( http_verb_t  verb)

get verb string representation

Parameters
[in]verb- verb to convert
Returns
verb string representation