void SocketStreamHost::Connect(const GURL& url) { //VLOG(1) << "SocketStreamHost::Connect url=" << url; WebRequestContext * req_context = new WebRequestContext(false); ProxyConfig* config = new ProxyConfig(); WebCache::get(false)->proxy()->GetLatestProxyConfig(config); std::string proxy(""); if(!config->proxy_rules().single_proxy.host_port_pair().host().empty()) proxy = config->proxy_rules().single_proxy.host_port_pair().ToString(); std::string exlist(""); ProxyConfigServiceAndroid* proxyConfigService = new ProxyConfigServiceAndroid(); proxyConfigService->UpdateProxySettings(proxy, exlist); ProxyService * proxy_service = net::ProxyService::CreateWithoutProxyResolver(proxyConfigService, 0 /* net_log */); //ProxyService * proxy_service = net::ProxyService::CreateWithoutProxyResolver(WebCache::get(false)->proxy(), 0 /* net_log */); SSLConfigService* ssl_config_service = net::SSLConfigService::CreateSystemSSLConfigService(); HostResolver *hostResolver = net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 0, 0); req_context->set_host_resolver(hostResolver); req_context->set_proxy_service(proxy_service); req_context->set_ssl_config_service(ssl_config_service); //req_context->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(hostResolver)); req_context->set_cert_verifier(new CertVerifier()); socket_ = net::SocketStreamJob::CreateSocketStreamJob(url, this, *req_context); socket_->set_context(req_context); socket_->SetUserData(kSocketHostKey, new SocketStreamInfo(this)); socket_->Connect(); }
ProxyError::ProxyError(ProxyPlugin *plugin, TCPClient *client, const QString& msg) : QDialog(NULL) , m_plugin(plugin) , m_client(client) { setupUi(this); setModal(false); setAttribute(Qt::WA_DeleteOnClose); setWindowIcon(Icon("error")); setButtonsPict(this); lblMessage->setText(msg); if (layout() && layout()->inherits("QBoxLayout")){ QBoxLayout *lay = static_cast<QBoxLayout*>(layout()); ProxyConfig *cfg = new ProxyConfig(this, m_plugin, NULL, static_cast <ClientPtr> (m_client)); lay->insertWidget(1, cfg); cfg->show(); setMinimumSize(sizeHint()); connect(this, SIGNAL(apply()), cfg, SLOT(apply())); } }
ProxyError::ProxyError(ProxyPlugin *plugin, TCPClient *client, const char *msg) : ProxyErrorBase(NULL, NULL, false, WDestructiveClose) { SET_WNDPROC("proxy") setIcon(Pict("error")); setButtonsPict(this); setCaption(caption()); m_plugin = plugin; m_client = client; if (msg && *msg) lblMessage->setText(i18n(msg)); if (layout() && layout()->inherits("QBoxLayout")){ QBoxLayout *lay = static_cast<QBoxLayout*>(layout()); ProxyConfig *cfg = new ProxyConfig(this, m_plugin, NULL, m_client); lay->insertWidget(1, cfg); cfg->show(); setMinimumSize(sizeHint()); connect(this, SIGNAL(apply()), cfg, SLOT(apply())); } }
TEST(HttpConnection, Http_Proxy) { ProxyConfig emptyConfig; EXPECT_EQ(emptyConfig.url(), ""); EXPECT_EQ(emptyConfig.type(), ProxyConfig::ProxyType::ProxyUndefined); ProxyConfig simpleConfig("myurl.com:911"); EXPECT_EQ(simpleConfig.url(), "myurl.com:911"); EXPECT_EQ(simpleConfig.type(), ProxyConfig::ProxyType::ProxyHTTP); ProxyConfig assignConfig; assignConfig = simpleConfig; EXPECT_EQ(assignConfig.url(), "myurl.com:911"); EXPECT_EQ(assignConfig.type(), ProxyConfig::ProxyType::ProxyHTTP); ProxyConfig moveConfig = std::move(simpleConfig); EXPECT_EQ(moveConfig.url(), "myurl.com:911"); EXPECT_EQ(moveConfig.type(), ProxyConfig::ProxyType::ProxyHTTP); }