http_response.h 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * responce.h
  3. *
  4. * Created on: 2021年8月16日
  5. * Author: pengzc
  6. */
  7. #ifndef JNI_HTTP_RESPONSE_H_
  8. #define JNI_HTTP_RESPONSE_H_
  9. #include <string>
  10. #include <map>
  11. #include <iostream>
  12. #include <fstream>
  13. namespace base {
  14. class HttpClient;
  15. class HttpResponse {
  16. public:
  17. HttpResponse();
  18. virtual ~HttpResponse();
  19. int StatusCode();
  20. int ErrorCode();
  21. std::string Body();
  22. std::string ErrorMessage();
  23. std::string Header(const std::string& key);
  24. std::map<std::string, std::string> header_;
  25. std::string* mutable_body();
  26. std::string ToString();
  27. private:
  28. friend class HttpClient;
  29. std::string body_;
  30. int status_code_;
  31. int error_code_;
  32. std::string error_message_;
  33. FILE* dst_file_;
  34. double total_time = 0;
  35. double name_lookup_time = 0;
  36. double connect_time = 0;
  37. double app_connect_time = 0;
  38. double pre_transfer_time = 0;
  39. double start_transfer_time = 0;
  40. double redirect_time = 0;
  41. int redirect_count = 0;
  42. };
  43. } /* namespace base */
  44. #endif /* JNI_HTTP_RESPONSE_H_ */