luat_http.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef LUAT_HTTP_H
  2. #define LUAT_HTTP_H
  3. #include "luat_base.h"
  4. #define LUAT_HTTP_GET 0
  5. #define LUAT_HTTP_POST 1
  6. #define LUAT_HTTP_PUT 2
  7. #define LUAT_HTTP_DELETE 3
  8. #define LUAT_HTTP_HEAD 4
  9. typedef struct luat_lib_http_body
  10. {
  11. uint8_t type;
  12. size_t size;
  13. void *ptr;
  14. void *next;
  15. }luat_lib_http_body_t;
  16. typedef struct luat_lib_http_headers
  17. {
  18. char** ptr;
  19. size_t size;
  20. }luat_lib_http_headers_t;
  21. typedef struct luat_lib_http_resp
  22. {
  23. int code;
  24. luat_lib_http_headers_t headers;
  25. luat_lib_http_body_t body;
  26. int luacb;
  27. }luat_lib_http_resp_t;
  28. typedef int (* luat_http_cb) (luat_lib_http_resp_t *resp);
  29. typedef struct luat_lib_http_req
  30. {
  31. uint8_t method;
  32. uint8_t timeout_s;
  33. char* url;
  34. size_t url_len;
  35. char* ca;
  36. size_t ca_len;
  37. luat_lib_http_headers_t headers;
  38. luat_lib_http_body_t body;
  39. int luacb;
  40. luat_http_cb httpcb;
  41. char dwpath[32];
  42. }luat_lib_http_req_t;
  43. int luat_http_req(luat_lib_http_req_t *req);
  44. void luat_http_req_gc(luat_lib_http_req_t *req);
  45. void luat_http_resp_gc(luat_lib_http_resp_t *req);
  46. #endif