diff options
| author | Richard Nyberg <rnyberg@murmeldjur.se> | 2006-10-29 14:54:21 +0000 |
|---|---|---|
| committer | Richard Nyberg <rnyberg@murmeldjur.se> | 2006-10-29 14:54:21 +0000 |
| commit | 1b7bb76fb78ec8f03999aaa9824f811f1fcf2c27 (patch) | |
| tree | 01fa022203f31fb8496735cd72031d1a753254cb /misc/http_client.h | |
| parent | 4f1d44297aa7605656db0c51955cf2968c91ac19 (diff) | |
| download | btpd-1b7bb76fb78ec8f03999aaa9824f811f1fcf2c27.tar.gz btpd-1b7bb76fb78ec8f03999aaa9824f811f1fcf2c27.zip | |
Add a simple http client. Since it uses libevent it's a better fit for btpd
than curl.
Diffstat (limited to 'misc/http_client.h')
| -rw-r--r-- | misc/http_client.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/misc/http_client.h b/misc/http_client.h new file mode 100644 index 0000000..2d0c24a --- /dev/null +++ b/misc/http_client.h @@ -0,0 +1,38 @@ +#ifndef BTPD_HTTP_CLIENT_H +#define BTPD_HTTP_CLIENT_H + +struct http_response { + enum { + HTTP_T_ERR, HTTP_T_CODE, HTTP_T_HEADER, HTTP_T_DATA, HTTP_T_DONE + } type; + union { + int error; + int code; + struct { + char *n; + char *v; + } header; + struct { + size_t l; + char *p; + } data; + } v; +}; + +struct http_url { + char *host; + char *uri; + uint16_t port; +}; + +struct http_req; + +typedef void (*http_cb)(struct http_req *, struct http_response *, void *); + +struct http_url *http_url_parse(const char *url); +void http_url_free(struct http_url *url); +int http_get(struct http_req **out, const char *url, const char *hdrs, + http_cb cb, void *arg); +void http_cancel(struct http_req *req); + +#endif |