Fix getter names.

GitOrigin-RevId: 19b6d420475d7ca7161fbb19658dcefa73de094f
This commit is contained in:
levlam 2018-04-19 15:23:54 +03:00
parent 05d17c3396
commit 8524a99faa
6 changed files with 29 additions and 21 deletions

View File

@ -148,7 +148,7 @@ class AuthData {
tmp_auth_key_.set_auth_flag(true);
}
Slice header() {
Slice get_header() {
if (use_pfs()) {
return tmp_auth_key_.need_header() ? Slice(header_) : Slice();
} else {

View File

@ -869,9 +869,9 @@ void SessionConnection::flush_packet() {
{
uint64 parent_message_id = 0;
auto storer = PacketStorer<CryptoImpl>(
queries, auth_data_->header(), std::move(to_ack), ping_id, ping_disconnect_delay() + 2, max_delay, max_after,
max_wait, future_salt_n, to_get_state_info, to_resend_answer, to_cancel_answer, auth_data_, &container_id,
&get_state_info_id, &resend_answer_id, &ping_message_id, &parent_message_id);
queries, auth_data_->get_header(), std::move(to_ack), ping_id, ping_disconnect_delay() + 2, max_delay,
max_after, max_wait, future_salt_n, to_get_state_info, to_resend_answer, to_cancel_answer, auth_data_,
&container_id, &get_state_info_id, &resend_answer_id, &ping_message_id, &parent_message_id);
auto quick_ack_token = use_quick_ack ? parent_message_id : 0;
send_crypto(storer, quick_ack_token);

View File

@ -1092,11 +1092,11 @@ class CliClient final : public Actor {
LOG(ERROR) << status.error();
return;
}
string bot_id = query.arg("bot_id").str();
string scope = query.arg("scope").str();
string public_key = query.arg("public_key").str();
string payload = query.arg("payload").str();
LOG(ERROR) << query.arg("callback_url");
string bot_id = query.get_arg("bot_id").str();
string scope = query.get_arg("scope").str();
string public_key = query.get_arg("public_key").str();
string payload = query.get_arg("payload").str();
LOG(ERROR) << query.get_arg("callback_url");
send_request(make_tl_object<td_api::getPassportAuthorizationForm>(to_integer<int32>(bot_id), scope, public_key,
payload, password));
} else if (op == "spaf") {

View File

@ -12,28 +12,29 @@
namespace td {
Slice HttpQuery::header(Slice key) const {
Slice HttpQuery::get_header(Slice key) const {
auto it = std::find_if(headers_.begin(), headers_.end(),
[&key](const std::pair<MutableSlice, MutableSlice> &s) { return s.first == key; });
return it == headers_.end() ? Slice() : it->second;
}
MutableSlice HttpQuery::arg(Slice key) const {
MutableSlice HttpQuery::get_arg(Slice key) const {
auto it = std::find_if(args_.begin(), args_.end(),
[&key](const std::pair<MutableSlice, MutableSlice> &s) { return s.first == key; });
return it == args_.end() ? MutableSlice() : it->second;
}
std::vector<std::pair<string, string>> HttpQuery::string_args() const {
std::vector<std::pair<string, string>> HttpQuery::get_args() const {
std::vector<std::pair<string, string>> res;
res.reserve(args_.size());
for (auto &it : args_) {
res.push_back(std::make_pair(it.first.str(), it.second.str()));
res.emplace_back(it.first.str(), it.second.str());
}
return res;
}
int HttpQuery::get_retry_after() const {
auto value = header("retry-after");
auto value = get_header("retry-after");
if (value.empty()) {
return 0;
}

View File

@ -33,11 +33,11 @@ class HttpQuery {
std::vector<HttpFile> files_;
MutableSlice content_;
Slice header(Slice key) const;
Slice get_header(Slice key) const;
MutableSlice arg(Slice key) const;
MutableSlice get_arg(Slice key) const;
std::vector<std::pair<string, string>> string_args() const;
std::vector<std::pair<string, string>> get_args() const;
int get_retry_after() const;
};

View File

@ -52,16 +52,23 @@ Status Wget::try_init() {
HttpHeaderCreator hc;
hc.init_get(url.query_);
bool was_host = false;
bool was_accept_encoding = false;
for (auto &header : headers_) {
if (header.first == "Host") { // TODO: lowercase
auto header_lower = to_lower(header.first);
if (header_lower == "host") {
was_host = true;
}
if (header_lower == "accept-encoding") {
was_accept_encoding = true;
}
hc.add_header(header.first, header.second);
}
if (!was_host) {
hc.add_header("Host", url.host_);
}
hc.add_header("Accept-Encoding", "gzip, deflate");
if (!was_accept_encoding) {
hc.add_header("Accept-Encoding", "gzip, deflate");
}
send_closure(connection_, &HttpOutboundConnection::write_next, BufferSlice(hc.finish().ok()));
send_closure(connection_, &HttpOutboundConnection::write_ok);
@ -89,7 +96,7 @@ void Wget::on_ok(HttpQueryPtr http_query_ptr) {
CHECK(promise_);
if (http_query_ptr->code_ == 302 && ttl_ > 0) {
LOG(DEBUG) << *http_query_ptr;
input_url_ = http_query_ptr->header("location").str();
input_url_ = http_query_ptr->get_header("location").str();
LOG(DEBUG) << input_url_;
ttl_--;
connection_.reset();
@ -98,7 +105,7 @@ void Wget::on_ok(HttpQueryPtr http_query_ptr) {
promise_.set_value(std::move(http_query_ptr));
stop();
} else {
on_error(Status::Error(PSLICE() << "http error: " << http_query_ptr->code_));
on_error(Status::Error(PSLICE() << "HTTP error: " << http_query_ptr->code_));
}
}