Minor HTTP-proxy fixes.

GitOrigin-RevId: 03d1ca116707c358cd1a414046222236ee2d09b4
This commit is contained in:
levlam 2018-08-17 19:03:07 +03:00
parent 25826e253d
commit c19ab1adbc
4 changed files with 8 additions and 2 deletions

View File

@ -70,6 +70,7 @@ void Transport::write(BufferWriter &&message, bool quick_ack) {
auto r_head = hc.finish();
CHECK(r_head.is_ok());
Slice src = r_head.ok();
// LOG(DEBUG) << src;
MutableSlice dst = message.prepare_prepend();
CHECK(dst.size() >= src.size()) << dst.size() << " >= " << src.size();
std::memcpy(dst.end() - src.size(), src.begin(), src.size());

View File

@ -631,7 +631,8 @@ void ConnectionCreator::disable_proxy_impl() {
void ConnectionCreator::on_proxy_changed(bool from_db) {
send_closure(G()->state_manager(), &StateManager::on_proxy,
active_proxy_id_ != 0 && proxies_[active_proxy_id_].type() != Proxy::Type::Mtproto);
active_proxy_id_ != 0 && proxies_[active_proxy_id_].type() != Proxy::Type::Mtproto &&
proxies_[active_proxy_id_].type() != Proxy::Type::HttpCaching);
if (!from_db) {
for (auto &child : children_) {
@ -989,6 +990,7 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
extra.stat);
if (proxy.use_socks5_proxy() || proxy.use_http_tcp_proxy()) {
VLOG(connections) << "client_loop: create new transparent proxy connection " << extra.debug_str;
class Callback : public TransparentProxy::Callback {
public:
explicit Callback(Promise<ConnectionData> promise, std::unique_ptr<detail::StatsCallback> stats_callback)
@ -1036,6 +1038,8 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
create_reference(token))};
}
} else {
VLOG(connections) << "client_loop: create new direct connection " << extra.debug_str;
ConnectionData data;
data.socket_fd = std::move(socket_fd);
data.stats_callback = std::move(stats_callback);

View File

@ -84,7 +84,7 @@ vector<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_all_connections(DcId dc_
}
if (only_http) {
if (!option.is_obfuscated_tcp_only() && !option.is_static()) {
if (!option.is_obfuscated_tcp_only() && !option.is_static() && (prefer_ipv6 || !option.is_ipv6())) {
info.use_http = true;
info.stat = &option_stat->http_stat;
options.push_back(info);

View File

@ -666,6 +666,7 @@ Status HttpReader::parse_head(MutableSlice head) {
query_->code_ = to_integer<int32>(parser.read_till(' '));
parser.skip(' ');
query_->reason_ = parser.read_till('\r');
LOG(DEBUG) << "Receive HTTP response " << query_->code_ << " " << query_->reason_;
} else {
auto url_version = parser.read_till('\r');
auto space_pos = url_version.rfind(' ');