http_client.h 746 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef HTTP_CLIENT_H_
  2. #define HTTP_CLIENT_H_
  3. #include "HttpRequest.h"
  4. /*
  5. #include <stdio.h>
  6. #include "http_client.h"
  7. int main(int argc, char* argv[]) {
  8. HttpRequest req;
  9. req.method = HTTP_GET;
  10. req.url = "www.baidu.com";
  11. HttpResponse res;
  12. int ret = http_client_send(&req, &res);
  13. printf("%s\n", req.dump(true,true).c_str());
  14. if (ret != 0) {
  15. printf("* Failed:%s:%d\n", http_client_strerror(ret), ret);
  16. }
  17. else {
  18. printf("%s\n", res.dump(true,true).c_str());
  19. }
  20. return ret;
  21. }
  22. */
  23. #define DEFAULT_HTTP_TIMEOUT 10 // s
  24. int http_client_send(HttpRequest* req, HttpResponse* res, int timeout = DEFAULT_HTTP_TIMEOUT);
  25. const char* http_client_strerror(int errcode);
  26. #endif // HTTP_CLIENT_H_