diff options
| author | 2023-01-28 17:49:02 +0100 | |
|---|---|---|
| committer | 2023-01-28 17:49:02 +0100 | |
| commit | 876bebd9ac904ca930117237edaf8c3dcae7a922 (patch) | |
| tree | 7e91e26c49e18fd80c7de93ff275ffce83fb14df /xs_curl.h | |
| parent | Bumped version. (diff) | |
| download | snac2-876bebd9ac904ca930117237edaf8c3dcae7a922.tar.gz snac2-876bebd9ac904ca930117237edaf8c3dcae7a922.tar.xz snac2-876bebd9ac904ca930117237edaf8c3dcae7a922.zip | |
Backport from xs.
Diffstat (limited to 'xs_curl.h')
| -rw-r--r-- | xs_curl.h | 22 |
1 files changed, 12 insertions, 10 deletions
| @@ -4,18 +4,18 @@ | |||
| 4 | 4 | ||
| 5 | #define _XS_CURL_H | 5 | #define _XS_CURL_H |
| 6 | 6 | ||
| 7 | d_char *xs_http_request(char *method, char *url, d_char *headers, | 7 | xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, |
| 8 | d_char *body, int b_size, int *status, | 8 | xs_str *body, int b_size, int *status, |
| 9 | d_char **payload, int *p_size, int timeout); | 9 | xs_str **payload, int *p_size, int timeout); |
| 10 | 10 | ||
| 11 | #ifdef XS_IMPLEMENTATION | 11 | #ifdef XS_IMPLEMENTATION |
| 12 | 12 | ||
| 13 | #include <curl/curl.h> | 13 | #include <curl/curl.h> |
| 14 | 14 | ||
| 15 | static size_t _header_callback(char *buffer, size_t size, | 15 | static size_t _header_callback(char *buffer, size_t size, |
| 16 | size_t nitems, d_char **userdata) | 16 | size_t nitems, xs_dict **userdata) |
| 17 | { | 17 | { |
| 18 | d_char *headers = *userdata; | 18 | xs_dict *headers = *userdata; |
| 19 | xs *l; | 19 | xs *l; |
| 20 | 20 | ||
| 21 | /* get the line */ | 21 | /* get the line */ |
| @@ -83,15 +83,17 @@ static int _post_callback(char *buffer, size_t size, | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | 85 | ||
| 86 | d_char *xs_http_request(char *method, char *url, d_char *headers, | 86 | xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, |
| 87 | d_char *body, int b_size, int *status, | 87 | xs_str *body, int b_size, int *status, |
| 88 | d_char **payload, int *p_size, int timeout) | 88 | xs_str **payload, int *p_size, int timeout) |
| 89 | /* does an HTTP request */ | 89 | /* does an HTTP request */ |
| 90 | { | 90 | { |
| 91 | d_char *response; | 91 | xs_dict *response; |
| 92 | CURL *curl; | 92 | CURL *curl; |
| 93 | struct curl_slist *list = NULL; | 93 | struct curl_slist *list = NULL; |
| 94 | char *k, *v, *p; | 94 | xs_dict *p; |
| 95 | xs_str *k; | ||
| 96 | xs_val *v; | ||
| 95 | long lstatus; | 97 | long lstatus; |
| 96 | struct _payload_data pd; | 98 | struct _payload_data pd; |
| 97 | 99 | ||