A clone of btpd with my configuration changes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.0 KiB

  1. #ifndef BTPD_HTTP_CLIENT_H
  2. #define BTPD_HTTP_CLIENT_H
  3. struct http_url {
  4. char *host;
  5. char *uri;
  6. uint16_t port;
  7. };
  8. struct http_url *http_url_parse(const char *url);
  9. void http_url_free(struct http_url *url);
  10. struct http_response {
  11. enum {
  12. HTTP_T_ERR, HTTP_T_CODE, HTTP_T_HEADER, HTTP_T_DATA, HTTP_T_DONE
  13. } type;
  14. union {
  15. int error;
  16. int code;
  17. struct {
  18. char *n;
  19. char *v;
  20. } header;
  21. struct {
  22. size_t l;
  23. char *p;
  24. } data;
  25. } v;
  26. };
  27. struct http_req;
  28. typedef void (*http_cb_t)(struct http_req *, struct http_response *, void *);
  29. int http_get(struct http_req **out, const char *url, const char *hdrs,
  30. http_cb_t cb, void *arg);
  31. void http_cancel(struct http_req *req);
  32. struct http_url *http_url_get(struct http_req *req);
  33. int http_want_read(struct http_req *req);
  34. int http_want_write(struct http_req *req);
  35. int http_read(struct http_req *req, int sd);
  36. int http_write(struct http_req *req, int sd);
  37. #endif