diff options
Diffstat (limited to 'xs_curl.h')
| -rw-r--r-- | xs_curl.h | 14 |
1 files changed, 8 insertions, 6 deletions
| @@ -4,8 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #define _XS_CURL_H | 5 | #define _XS_CURL_H |
| 6 | 6 | ||
| 7 | xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, | 7 | xs_dict *xs_http_request(const char *method, const char *url, |
| 8 | xs_str *body, int b_size, int *status, | 8 | const xs_dict *headers, |
| 9 | const xs_str *body, int b_size, int *status, | ||
| 9 | xs_str **payload, int *p_size, int timeout); | 10 | xs_str **payload, int *p_size, int timeout); |
| 10 | 11 | ||
| 11 | #ifdef XS_IMPLEMENTATION | 12 | #ifdef XS_IMPLEMENTATION |
| @@ -83,8 +84,9 @@ static int _post_callback(char *buffer, size_t size, | |||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | 86 | ||
| 86 | xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, | 87 | xs_dict *xs_http_request(const char *method, const char *url, |
| 87 | xs_str *body, int b_size, int *status, | 88 | const xs_dict *headers, |
| 89 | const xs_str *body, int b_size, int *status, | ||
| 88 | xs_str **payload, int *p_size, int timeout) | 90 | xs_str **payload, int *p_size, int timeout) |
| 89 | /* does an HTTP request */ | 91 | /* does an HTTP request */ |
| 90 | { | 92 | { |
| @@ -136,7 +138,7 @@ xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, | |||
| 136 | sprintf(tmp, "content-length: %d", b_size); | 138 | sprintf(tmp, "content-length: %d", b_size); |
| 137 | list = curl_slist_append(list, tmp); | 139 | list = curl_slist_append(list, tmp); |
| 138 | 140 | ||
| 139 | pd.data = body; | 141 | pd.data = (char *)body; |
| 140 | pd.size = b_size; | 142 | pd.size = b_size; |
| 141 | pd.offset = 0; | 143 | pd.offset = 0; |
| 142 | 144 | ||
| @@ -146,7 +148,7 @@ xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, | |||
| 146 | } | 148 | } |
| 147 | 149 | ||
| 148 | /* fill the request headers */ | 150 | /* fill the request headers */ |
| 149 | p = headers; | 151 | p = (xs_dict *)headers; |
| 150 | while (xs_dict_iter(&p, &k, &v)) { | 152 | while (xs_dict_iter(&p, &k, &v)) { |
| 151 | xs *h = xs_fmt("%s: %s", k, v); | 153 | xs *h = xs_fmt("%s: %s", k, v); |
| 152 | 154 | ||