/*
 * responce.cpp
 *
 *  Created on: 2021年8月16日
 *      Author: pengzc
 */

#include "http_response.h"
#include "base/strings.hpp"

namespace base {

HttpResponse::HttpResponse() {
  // TODO 自动生成的构造函数存根
  status_code_ = 0;
  error_code_ = 0;
  dst_file_ = NULL;
}

HttpResponse::~HttpResponse() {
  // TODO 自动生成的析构函数存根
}

int HttpResponse::StatusCode() {
  return status_code_;
}

int HttpResponse::ErrorCode() {
  return error_code_;
}

std::string HttpResponse::Body() {
  return body_;
}

std::string HttpResponse::ErrorMessage() {
  return error_message_;
}

#include "utils/Log.h"
std::string HttpResponse::Header(const std::string& key) {
  return header_[key];
}

std::string* HttpResponse::mutable_body() {
  return &body_;
}

std::string HttpResponse::ToString() {
  std::string str;
         str += "HTTP Request Info\n";
         str += base::format("\t total_time: %lf\n", total_time);
         str += base::format("\t name_lookup_time: %lf\n", name_lookup_time);
         str += base::format("\t connect_time: %lf\n", connect_time);
         str += base::format("\t app_connect_time: %lf\n", app_connect_time);
         str += base::format("\t pre_transfer_time: %lf\n", pre_transfer_time);
         str += base::format("\t start_transfer_time: %lf\n", start_transfer_time);
         str += base::format("\t redirect_time: %lf\n", redirect_time);
         str += base::format("\t redirect_count: %d\n", redirect_count);
  return str;
}

} /* namespace base */
