Unify enum constant name style.

GitOrigin-RevId: 2e36eef9b54c23da0d1bc9beb7e07af8835f702d
This commit is contained in:
levlam 2020-06-15 04:23:47 +03:00
parent 715146c65c
commit ea4841a37c
10 changed files with 36 additions and 36 deletions

View File

@ -29,7 +29,7 @@ Result<size_t> Transport::read_next(BufferSlice *message, uint32 *quick_ack) {
if (r_size.is_error() || r_size.ok() != 0) {
return r_size;
}
if (http_query_.type_ != HttpQuery::Type::RESPONSE) {
if (http_query_.type_ != HttpQuery::Type::Response) {
return Status::Error("Unexpected HTTP query type");
}
if (http_query_.container_.size() != 2u) {

View File

@ -332,7 +332,7 @@ Result<string> check_url(Slice url) {
}
TRY_RESULT(http_url, parse_url(url));
if (is_tg || is_ton) {
if (tolower_begins_with(url, "http://") || http_url.protocol_ == HttpUrl::Protocol::HTTPS ||
if (tolower_begins_with(url, "http://") || http_url.protocol_ == HttpUrl::Protocol::Https ||
!http_url.userinfo_.empty() || http_url.specified_port_ != 0 || http_url.is_ipv6_) {
return Status::Error(is_tg ? Slice("Wrong tg URL") : Slice("Wrong ton URL"));
}

View File

@ -164,7 +164,7 @@ void HttpConnectionBase::loop() {
}
if (state_ == State::Close) {
LOG_IF(INFO, fd_.need_flush_write()) << "Close nonempty connection";
LOG_IF(INFO, want_read && (fd_.input_buffer().size() > 0 || current_query_->type_ != HttpQuery::Type::EMPTY))
LOG_IF(INFO, want_read && (fd_.input_buffer().size() > 0 || current_query_->type_ != HttpQuery::Type::Empty))
<< "Close connection while reading request/response";
return stop();
}

View File

@ -48,20 +48,20 @@ int HttpQuery::get_retry_after() const {
StringBuilder &operator<<(StringBuilder &sb, const HttpQuery &q) {
switch (q.type_) {
case HttpQuery::Type::EMPTY:
case HttpQuery::Type::Empty:
sb << "EMPTY";
return sb;
case HttpQuery::Type::GET:
case HttpQuery::Type::Get:
sb << "GET";
break;
case HttpQuery::Type::POST:
case HttpQuery::Type::Post:
sb << "POST";
break;
case HttpQuery::Type::RESPONSE:
case HttpQuery::Type::Response:
sb << "RESPONSE";
break;
}
if (q.type_ == HttpQuery::Type::RESPONSE) {
if (q.type_ == HttpQuery::Type::Response) {
sb << ":" << q.code_ << ":" << q.reason_;
} else {
sb << ":" << q.url_path_;

View File

@ -19,10 +19,10 @@ namespace td {
class HttpQuery {
public:
enum class Type : int8 { EMPTY, GET, POST, RESPONSE };
enum class Type : int8 { Empty, Get, Post, Response };
td::vector<BufferSlice> container_;
Type type_ = Type::EMPTY;
Type type_ = Type::Empty;
int32 code_ = 0;
MutableSlice url_path_;
td::vector<std::pair<MutableSlice, MutableSlice>> args_;

View File

@ -663,12 +663,12 @@ Status HttpReader::parse_head(MutableSlice head) {
parser.skip(' ');
// GET POST HTTP/1.1
if (type == "GET") {
query_->type_ = HttpQuery::Type::GET;
query_->type_ = HttpQuery::Type::Get;
} else if (type == "POST") {
query_->type_ = HttpQuery::Type::POST;
query_->type_ = HttpQuery::Type::Post;
} else if (type.size() >= 4 && type.substr(0, 4) == "HTTP") {
if (type == "HTTP/1.1" || type == "HTTP/1.0") {
query_->type_ = HttpQuery::Type::RESPONSE;
query_->type_ = HttpQuery::Type::Response;
} else {
LOG(INFO) << "Unsupported HTTP version: " << type;
return Status::Error(505, "HTTP Version Not Supported");
@ -680,7 +680,7 @@ Status HttpReader::parse_head(MutableSlice head) {
query_->args_.clear();
if (query_->type_ == HttpQuery::Type::RESPONSE) {
if (query_->type_ == HttpQuery::Type::Response) {
query_->code_ = to_integer<int32>(parser.read_till(' '));
parser.skip(' ');
query_->reason_ = parser.read_till('\r');

View File

@ -74,7 +74,7 @@ Status Wget::try_init() {
TRY_STATUS(addr.init_host_port(url.host_, url.port_, prefer_ipv6_));
TRY_RESULT(fd, SocketFd::open(addr));
if (url.protocol_ == HttpUrl::Protocol::HTTP) {
if (url.protocol_ == HttpUrl::Protocol::Http) {
connection_ = create_actor<HttpOutboundConnection>("Connect", std::move(fd), SslStream{},
std::numeric_limits<std::size_t>::max(), 0, 0,
ActorOwn<HttpOutboundConnection::Callback>(actor_id(this)));

View File

@ -17,10 +17,10 @@ namespace td {
string HttpUrl::get_url() const {
string result;
switch (protocol_) {
case Protocol::HTTP:
case Protocol::Http:
result += "http://";
break;
case Protocol::HTTPS:
case Protocol::Https:
result += "https://";
break;
default:
@ -49,9 +49,9 @@ Result<HttpUrl> parse_url(Slice url, HttpUrl::Protocol default_protocol) {
if (parser.start_with("://")) {
parser.advance(3);
if (protocol_str == "http") {
protocol = HttpUrl::Protocol::HTTP;
protocol = HttpUrl::Protocol::Http;
} else if (protocol_str == "https") {
protocol = HttpUrl::Protocol::HTTPS;
protocol = HttpUrl::Protocol::Https;
} else {
return Status::Error("Unsupported URL protocol");
}
@ -99,10 +99,10 @@ Result<HttpUrl> parse_url(Slice url, HttpUrl::Protocol default_protocol) {
int specified_port = port;
if (port == 0) {
if (protocol == HttpUrl::Protocol::HTTP) {
if (protocol == HttpUrl::Protocol::Http) {
port = 80;
} else {
CHECK(protocol == HttpUrl::Protocol::HTTPS);
CHECK(protocol == HttpUrl::Protocol::Https);
port = 443;
}
}
@ -169,7 +169,7 @@ Result<HttpUrl> parse_url(Slice url, HttpUrl::Protocol default_protocol) {
}
StringBuilder &operator<<(StringBuilder &sb, const HttpUrl &url) {
sb << tag("protocol", url.protocol_ == HttpUrl::Protocol::HTTP ? "HTTP" : "HTTPS") << tag("userinfo", url.userinfo_)
sb << tag("protocol", url.protocol_ == HttpUrl::Protocol::Http ? "HTTP" : "HTTPS") << tag("userinfo", url.userinfo_)
<< tag("host", url.host_) << tag("port", url.port_) << tag("query", url.query_);
return sb;
}

View File

@ -15,7 +15,7 @@ namespace td {
class HttpUrl {
public:
enum class Protocol { HTTP, HTTPS } protocol_ = Protocol::HTTP;
enum class Protocol { Http, Https } protocol_ = Protocol::Http;
string userinfo_;
string host_;
bool is_ipv6_ = false;
@ -37,7 +37,7 @@ class HttpUrl {
};
Result<HttpUrl> parse_url(Slice url,
HttpUrl::Protocol default_protocol = HttpUrl::Protocol::HTTP) TD_WARN_UNUSED_RESULT;
HttpUrl::Protocol default_protocol = HttpUrl::Protocol::Http) TD_WARN_UNUSED_RESULT;
StringBuilder &operator<<(StringBuilder &sb, const HttpUrl &url);

View File

@ -104,7 +104,7 @@ string winerror_to_string(int code);
#endif
class Status {
enum class ErrorType : int8 { general, os };
enum class ErrorType : int8 { General, Os };
public:
Status() = default;
@ -129,7 +129,7 @@ class Status {
}
static Status Error(int err, Slice message = Slice()) TD_WARN_UNUSED_RESULT {
return Status(false, ErrorType::general, err, message);
return Status(false, ErrorType::General, err, message);
}
static Status Error(Slice message) TD_WARN_UNUSED_RESULT {
@ -138,13 +138,13 @@ class Status {
#if TD_PORT_WINDOWS
static Status WindowsError(int saved_error, Slice message) TD_WARN_UNUSED_RESULT {
return Status(false, ErrorType::os, saved_error, message);
return Status(false, ErrorType::Os, saved_error, message);
}
#endif
#if TD_PORT_POSIX
static Status PosixError(int32 saved_errno, Slice message) TD_WARN_UNUSED_RESULT {
return Status(false, ErrorType::os, saved_errno, message);
return Status(false, ErrorType::Os, saved_errno, message);
}
#endif
@ -154,7 +154,7 @@ class Status {
template <int Code>
static Status Error() {
static Status status(true, ErrorType::general, Code, "");
static Status status(true, ErrorType::General, Code, "");
return status.clone_static();
}
@ -164,10 +164,10 @@ class Status {
}
Info info = get_info();
switch (info.error_type) {
case ErrorType::general:
case ErrorType::General:
sb << "[Error";
break;
case ErrorType::os:
case ErrorType::Os:
#if TD_PORT_POSIX
sb << "[PosixError : " << strerror_safe(info.error_code);
#elif TD_PORT_WINDOWS
@ -246,9 +246,9 @@ class Status {
}
Info info = get_info();
switch (info.error_type) {
case ErrorType::general:
case ErrorType::General:
return message().str();
case ErrorType::os:
case ErrorType::Os:
#if TD_PORT_POSIX
return strerror_safe(info.error_code).str();
#elif TD_PORT_WINDOWS
@ -276,10 +276,10 @@ class Status {
CHECK(is_error());
Info info = get_info();
switch (info.error_type) {
case ErrorType::general:
case ErrorType::General:
return Error(code(), PSLICE() << prefix << message());
case ErrorType::os:
return Status(false, ErrorType::os, code(), PSLICE() << prefix << message());
case ErrorType::Os:
return Status(false, ErrorType::Os, code(), PSLICE() << prefix << message());
default:
UNREACHABLE();
return {};