int (*read)(struct uclient *cl, char *buf, unsigned int len);
int (*write)(struct uclient *cl, const char *buf, unsigned int len);
+ int (*pending_bytes)(struct uclient *cl, bool write);
};
void uclient_backend_set_error(struct uclient *cl, int code);
return 0;
}
+static int
+uclient_http_pending_bytes(struct uclient *cl, bool write)
+{
+ struct uclient_http *uh = container_of(cl, struct uclient_http, uc);
+
+ return ustream_pending_data(uh->us, write);
+}
+
const struct uclient_backend uclient_backend_http = {
.prefix = uclient_http_prefix,
.read = uclient_http_read,
.write = uclient_http_send_data,
.request = uclient_http_request_done,
+ .pending_bytes = uclient_http_pending_bytes,
};
return cl->backend->read(cl, buf, len);
}
+int uclient_pending_bytes(struct uclient *cl, bool write)
+{
+ if (!cl->backend->pending_bytes)
+ return -1;
+
+ return cl->backend->pending_bytes(cl, write);
+}
+
void uclient_disconnect(struct uclient *cl)
{
uloop_timeout_cancel(&cl->connection_timeout);
int uclient_read(struct uclient *cl, char *buf, int len);
int uclient_write(struct uclient *cl, const char *buf, int len);
+int uclient_pending_bytes(struct uclient *cl, bool write);
int uclient_request(struct uclient *cl);
char *uclient_get_addr(char *dest, int *port, union uclient_addr *a);