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

#ifndef JNI_HTTP_RESPONSE_H_
#define JNI_HTTP_RESPONSE_H_

#include <string>
#include <map>
#include <iostream>
#include <fstream>

namespace base {

class HttpClient;

class HttpResponse {
public:
  HttpResponse();
  virtual ~HttpResponse();

  int StatusCode();
  int ErrorCode();
  std::string Body();
  std::string ErrorMessage();
  std::string Header(const std::string& key);
  std::map<std::string, std::string> header_;

  std::string* mutable_body();

  std::string ToString();
private:
  friend class HttpClient;
  std::string body_;
  int status_code_;
  int error_code_;
  std::string error_message_;
  FILE* dst_file_;

  double total_time = 0;
  double name_lookup_time = 0;
  double connect_time = 0;
  double app_connect_time = 0;
  double pre_transfer_time = 0;
  double start_transfer_time = 0;
  double redirect_time = 0;
  int redirect_count = 0;
};

} /* namespace base */

#endif /* JNI_HTTP_RESPONSE_H_ */
