http_response.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * responce.cpp
  3. *
  4. * Created on: 2021年8月16日
  5. * Author: pengzc
  6. */
  7. #include "http_response.h"
  8. #include "base/strings.hpp"
  9. namespace base {
  10. HttpResponse::HttpResponse() {
  11. // TODO 自动生成的构造函数存根
  12. status_code_ = 0;
  13. error_code_ = 0;
  14. dst_file_ = NULL;
  15. }
  16. HttpResponse::~HttpResponse() {
  17. // TODO 自动生成的析构函数存根
  18. }
  19. int HttpResponse::StatusCode() {
  20. return status_code_;
  21. }
  22. int HttpResponse::ErrorCode() {
  23. return error_code_;
  24. }
  25. std::string HttpResponse::Body() {
  26. return body_;
  27. }
  28. std::string HttpResponse::ErrorMessage() {
  29. return error_message_;
  30. }
  31. #include "utils/Log.h"
  32. std::string HttpResponse::Header(const std::string& key) {
  33. return header_[key];
  34. }
  35. std::string* HttpResponse::mutable_body() {
  36. return &body_;
  37. }
  38. std::string HttpResponse::ToString() {
  39. std::string str;
  40. str += "HTTP Request Info\n";
  41. str += base::format("\t total_time: %lf\n", total_time);
  42. str += base::format("\t name_lookup_time: %lf\n", name_lookup_time);
  43. str += base::format("\t connect_time: %lf\n", connect_time);
  44. str += base::format("\t app_connect_time: %lf\n", app_connect_time);
  45. str += base::format("\t pre_transfer_time: %lf\n", pre_transfer_time);
  46. str += base::format("\t start_transfer_time: %lf\n", start_transfer_time);
  47. str += base::format("\t redirect_time: %lf\n", redirect_time);
  48. str += base::format("\t redirect_count: %d\n", redirect_count);
  49. return str;
  50. }
  51. } /* namespace base */