#ifndef REMOTING_BASE_HTTP_STATUS_H_
#define REMOTING_BASE_HTTP_STATUS_H_
#include <string>
#include "net/base/net_errors.h"
#include "net/http/http_status_code.h"
namespace remoting {
namespace protobufhttpclient {
class Status;
}
class HttpStatus {
public:
enum class Code : int {
OK = 0,
CANCELLED = 1,
UNKNOWN = 2,
INVALID_ARGUMENT = 3,
DEADLINE_EXCEEDED = 4,
NOT_FOUND = 5,
ALREADY_EXISTS = 6,
PERMISSION_DENIED = 7,
RESOURCE_EXHAUSTED = 8,
FAILED_PRECONDITION = 9,
ABORTED = 10,
OUT_OF_RANGE = 11,
UNIMPLEMENTED = 12,
INTERNAL = 13,
UNAVAILABLE = 14,
DATA_LOSS = 15,
UNAUTHENTICATED = 16,
NETWORK_ERROR = 17,
};
static const HttpStatus& OK();
explicit HttpStatus(net::HttpStatusCode http_status_code);
explicit HttpStatus(net::Error net_error);
explicit HttpStatus(const protobufhttpclient::Status& status);
HttpStatus(Code code, const std::string& error_message);
HttpStatus(const protobufhttpclient::Status& status,
const std::string& response_body);
HttpStatus(net::HttpStatusCode http_status_code,
const std::string& response_body);
~HttpStatus();
bool operator==(const HttpStatus& other) const;
bool ok() const;
Code error_code() const { return error_code_; }
const std::string& error_message() const { return error_message_; }
const std::string& response_body() const { return response_body_; }
private:
Code error_code_;
std::string error_message_;
std::string response_body_;
};
}
#endif