1 #ifndef __LIBUBOX_UCLIENT_H
2 #define __LIBUBOX_UCLIENT_H
4 #include <libubox/blob.h>
5 #include <libubox/ustream.h>
6 #include <libubox/ustream-ssl.h>
9 struct uclient_backend;
12 const struct uclient_backend *backend;
13 const struct uclient_cb *cb;
15 struct uclient_url *url;
21 struct blob_attr *meta;
23 struct uloop_timeout timeout;
27 void (*data_read)(struct uclient *cl);
28 void (*data_sent)(struct uclient *cl);
29 void (*data_eof)(struct uclient *cl);
30 void (*header_done)(struct uclient *cl);
31 void (*error)(struct uclient *cl);
34 struct uclient *uclient_new(const char *url, const struct uclient_cb *cb);
35 void uclient_free(struct uclient *cl);
37 int uclient_connect_url(struct uclient *cl, const char *url_str);
39 static inline int uclient_connect(struct uclient *cl)
41 return uclient_connect_url(cl, NULL);
45 int uclient_read(struct uclient *cl, char *buf, int len);
46 int uclient_write(struct uclient *cl, char *buf, int len);
47 int uclient_request(struct uclient *cl);
50 extern const struct uclient_backend uclient_backend_http;
52 int uclient_http_set_header(struct uclient *cl, const char *name, const char *value);
53 int uclient_http_reset_headers(struct uclient *cl, const char *name, const char *value);
54 int uclient_http_set_request_type(struct uclient *cl, const char *type);
55 bool uclient_http_redirect(struct uclient *cl);