Minor improvements.

GitOrigin-RevId: 2f2099d91867ec302ff2d9426b6b088c8c625720
This commit is contained in:
levlam 2018-11-01 20:08:20 +03:00
parent 03604bb367
commit 5d5c55596e
5 changed files with 13 additions and 12 deletions

View File

@ -291,8 +291,8 @@ Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::rpc_
}
Status SessionConnection::on_packet(const MsgInfo &info, uint64 req_msg_id, const mtproto_api::rpc_error &rpc_error) {
VLOG(mtproto) << "ERROR [code:" << rpc_error.error_code_ << "] [msg:" << rpc_error.error_message_.str().c_str() << "]"
<< " " << tag("req_msg_id", req_msg_id);
VLOG(mtproto) << "ERROR " << tag("code", rpc_error.error_code_) << tag("message", rpc_error.error_message_)
<< tag("req_msg_id", req_msg_id);
if (req_msg_id != 0) {
callback_->on_message_result_error(req_msg_id, rpc_error.error_code_, as_buffer_slice(rpc_error.error_message_));
} else {

View File

@ -10,6 +10,7 @@
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQuery.h"
#include "td/actor/actor.h"
#include "td/utils/buffer.h"

View File

@ -146,7 +146,7 @@ Session::Session(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared>
last_activity_timestamp_ = Time::now();
}
bool Session::can_destroy_auth_key() {
bool Session::can_destroy_auth_key() const {
return need_destroy_;
}
@ -1006,10 +1006,10 @@ void Session::connection_close(ConnectionInfo *info) {
CHECK(info->state == ConnectionInfo::State::Empty);
}
bool Session::need_send_bind_key() {
bool Session::need_send_bind_key() const {
return auth_data_.use_pfs() && !auth_data_.get_bind_flag() && auth_data_.get_tmp_auth_key().id() != tmp_auth_key_id_;
}
bool Session::need_send_query() {
bool Session::need_send_query() const {
return !close_flag_ && (!auth_data_.use_pfs() || auth_data_.get_bind_flag()) && !pending_queries_.empty() &&
!can_destroy_auth_key();
}

View File

@ -222,9 +222,9 @@ class Session final
void connection_close(ConnectionInfo *info);
void connection_flush(ConnectionInfo *info);
void connection_send_query(ConnectionInfo *info, NetQueryPtr &&net_query, uint64 message_id = 0);
bool need_send_bind_key();
bool need_send_query();
bool can_destroy_auth_key();
bool need_send_bind_key() const;
bool need_send_query() const;
bool can_destroy_auth_key() const;
bool connection_send_bind_key(ConnectionInfo *info);
void on_result(NetQueryPtr query) override;

View File

@ -124,7 +124,7 @@ Result<size_t> HttpReader::read_next(HttpQuery *query) {
return Status::Error(413, PSLICE() << "Request Entity Too Large: content length is " << content_length_);
}
if (std::strstr(content_type_lowercased_.c_str(), "multipart/form-data")) {
if (content_type_lowercased_.find("multipart/form-data") != string::npos) {
state_ = ReadMultipartFormData;
const char *p = std::strstr(content_type_lowercased_.c_str(), "boundary");
@ -157,8 +157,8 @@ Result<size_t> HttpReader::read_next(HttpQuery *query) {
form_data_parse_state_ = SkipPrologue;
form_data_read_length_ = 0;
form_data_skipped_length_ = 0;
} else if (std::strstr(content_type_lowercased_.c_str(), "application/x-www-form-urlencoded") ||
std::strstr(content_type_lowercased_.c_str(), "application/json")) {
} else if (content_type_lowercased_.find("application/x-www-form-urlencoded") != string::npos ||
content_type_lowercased_.find("application/json") != string::npos) {
state_ = ReadArgs;
} else {
form_data_skipped_length_ = 0;
@ -210,7 +210,7 @@ Result<size_t> HttpReader::read_next(HttpQuery *query) {
if (flow_sink_.is_ready()) {
query_->container_.emplace_back(content_->cut_head(size).move_as_buffer_slice());
Status result;
if (std::strstr(content_type_lowercased_.c_str(), "application/x-www-form-urlencoded")) {
if (content_type_lowercased_.find("application/x-www-form-urlencoded") != string::npos) {
result = parse_parameters(query_->container_.back().as_slice());
} else {
result = parse_json_parameters(query_->container_.back().as_slice());