http.h 886 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (C) 2019-2020 Alibaba Group Holding Limited
  3. */
  4. #ifndef __HTTP_H__
  5. #define __HTTP_H__
  6. #include "util/network.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. typedef struct http {
  11. char *path;
  12. char *host;
  13. uint8_t *buffer;
  14. int buffer_offset;
  15. char *url;
  16. int port;
  17. network_t net;
  18. } http_t;
  19. // char *json_getvalue(char *body, char *key, int *len);
  20. http_t *http_init(const char *path);
  21. int http_head_sets(http_t *http, const char *key, const char *value);
  22. int http_head_seti(http_t *http, const char *key, int value);
  23. int http_post(http_t *http, char *playload, int timeoutms);
  24. int http_get(http_t *http, int timeoutms);
  25. int http_wait_resp(http_t *http, char **head_end, int timeoutms);
  26. char *http_head_get(http_t *http, char *key, int *length);
  27. char *http_read_data(http_t *http);
  28. int http_deinit(http_t *http);
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. #endif