8#define CREQ_ERROR_SUCCESS 0
11#define CREQ_ERROR_MEMORY_ALLOCATION 1
14#define CREQ_ERROR_CURL 2
17#define CREQ_ERROR_SETTING_GET_PARAMS 3
22#define CREQ_ERROR_PARAMS_TOO_LONG 4
void creq_set_timeout(CREQ_CTX *ctx, long timesec)
Sets timeout for both connection and data transfer.
Definition crequests.c:337
void creq_set_proxy(CREQ_CTX *ctx, char *proxy)
Sets a proxy for sending requests.
Definition crequests.c:151
void creq_add_param(CREQ_CTX *ctx, char *key, char *value)
Sets a GET/POST param.
Definition crequests.c:953
char * creq_get_content(CREQ_CTX *)
Returns the content of the request.
Definition crequests.c:1024
char * creq_get_response_header(CREQ_CTX *ctx, char *header)
Returns the value for a given header name.
Definition crequests.c:1118
void creq_close(CREQ_CTX *ctx)
Cleans up the library and memory after using it.
Definition crequests.c:234
void creq_head(CREQ_CTX *ctx, char *url)
Sends a head request.
Definition crequests.c:758
char * creq_error(CREQ_CTX *)
Returns the possible error message.
Definition crequests.c:894
void creq_set_allow_redirects(CREQ_CTX *, int)
Tells the library if it should follow redirection.
Definition crequests.c:275
CREQ_CTX * creq_init(void)
Initialize the creq library for a new request.
Definition crequests.c:52
void creq_add_header(CREQ_CTX *ctx, char *header)
Adds a header to the header list for sending.
Definition crequests.c:111
void creq_post(CREQ_CTX *ctx, char *url)
Sends a post request.
Definition crequests.c:722
void creq_get(CREQ_CTX *ctx, char *url)
Sends a GET request to the specified URL.
Definition crequests.c:651
void creq_set_useragent(CREQ_CTX *ctx, char *ua)
Add user-agent to the request header.
Definition crequests.c:585
void creq_set_verify(CREQ_CTX *ctx, int val)
Enables/disables SSL/TLS verification.
Definition crequests.c:291
Definition crequests.h:83
CREQ_REQUEST_DATA * request
request structure
Definition crequests.h:87
CURLcode curl_code
possible curl error code
Definition crequests.h:88
CURL * handle
Internal curl handle.
Definition crequests.h:85
CREQ_RESPONSE_DATA * response
response structure
Definition crequests.h:86
int err_code
Any possible error code (0 means success)
Definition crequests.h:84
short int _is_redirection
Internal member.
Definition crequests.h:89
Structure to hold the GET/POST parameters.
Definition crequests.h:36
char * value
value of the get parameter
Definition crequests.h:38
CREQ_GET_PARAMS * next
Pointer to the next node.
Definition crequests.h:39
char * key
key of the get parameter
Definition crequests.h:37
Definition crequests.h:55
char * url
URL found in 'Location' header.
Definition crequests.h:56
CREQ_REDIRECTION_CHAIN * next
pointer to the next node
Definition crequests.h:57
Definition crequests.h:62
CREQ_GET_PARAMS * params
parameters of POST & GET requests
Definition crequests.h:66
char * ua
User-Agent (will be freed by library)
Definition crequests.h:65
char * proxy
String for proxy to use.
Definition crequests.h:71
char * url
URL to get (will be freed by library)
Definition crequests.h:67
struct curl_slist * headers
curl will free this option for you
Definition crequests.h:69
int allow_redirects
Should we follow redirections?
Definition crequests.h:63
int verify
should we verify TLS/SSL connection?
Definition crequests.h:64
long request_timeout
Maximum time (in seconds) before timeout.
Definition crequests.h:68
Definition crequests.h:74
char * url
final destination URL
Definition crequests.h:76
long status_code
returned HTTP status code
Definition crequests.h:75
size_t len
Length of the body of the request.
Definition crequests.h:78
CREQ_HEADER * headers
linked-list of response headers
Definition crequests.h:79
CREQ_REDIRECTION_CHAIN * follow_chain
Linked-list of redirections.
Definition crequests.h:80
char * mem
pointer to memory we keep the body of the request
Definition crequests.h:77