void nsHttpConnectionInfo::SetOriginServer(const nsACString &host, int32_t port) { mHost = host; mPort = port == -1 ? DefaultPort() : port; // // build hash key: // // the hash key uniquely identifies the connection type. two connections // are "equal" if they end up talking the same protocol to the same server // and are both used for anonymous or non-anonymous connection only; // anonymity of the connection is setup later from nsHttpChannel::AsyncOpen // where we know we use anonymous connection (LOAD_ANONYMOUS load flag) // const char *keyHost; int32_t keyPort; if (mUsingHttpProxy && !mUsingConnect) { keyHost = ProxyHost(); keyPort = ProxyPort(); } else { keyHost = Host(); keyPort = Port(); } mHashKey.AssignLiteral("...."); mHashKey.Append(keyHost); mHashKey.Append(':'); mHashKey.AppendInt(keyPort); if (mUsingHttpProxy) mHashKey.SetCharAt('P', 0); if (mUsingSSL) mHashKey.SetCharAt('S', 1); // NOTE: for transparent proxies (e.g., SOCKS) we need to encode the proxy // info in the hash key (this ensures that we will continue to speak the // right protocol even if our proxy preferences change). // // NOTE: for SSL tunnels add the proxy information to the cache key. // We cannot use the proxy as the host parameter (as we do for non SSL) // because this is a single host tunnel, but we need to include the proxy // information so that a change in proxy config will mean this connection // is not reused if ((!mUsingHttpProxy && ProxyHost()) || (mUsingHttpProxy && mUsingConnect)) { mHashKey.AppendLiteral(" ("); mHashKey.Append(ProxyType()); mHashKey.Append(':'); mHashKey.Append(ProxyHost()); mHashKey.Append(':'); mHashKey.AppendInt(ProxyPort()); mHashKey.Append(')'); } }
void ICQClient::setupProxy() { Sockets::proxyType = ProxyType(); Sockets::proxyHost = ProxyHost; Sockets::proxyPort = ProxyPort(); Sockets::proxyAuth = ProxyAuth(); Sockets::proxyUser = ProxyUser; Sockets::proxyPasswd = ProxyPasswd; }
NS_IMETHODIMP nsHttpChannelAuthProvider::AddAuthorizationHeaders() { LOG(("nsHttpChannelAuthProvider::AddAuthorizationHeaders? " "[this=%p channel=%p]\n", this, mAuthChannel)); NS_ASSERTION(mAuthChannel, "Channel not initialized"); nsCOMPtr<nsIProxyInfo> proxyInfo; nsresult rv = mAuthChannel->GetProxyInfo(getter_AddRefs(proxyInfo)); if (NS_FAILED(rv)) return rv; if (proxyInfo) { mProxyInfo = do_QueryInterface(proxyInfo); if (!mProxyInfo) return NS_ERROR_NO_INTERFACE; } uint32_t loadFlags; rv = mAuthChannel->GetLoadFlags(&loadFlags); if (NS_FAILED(rv)) return rv; // this getter never fails nsHttpAuthCache *authCache = gHttpHandler->AuthCache(); // check if proxy credentials should be sent const char *proxyHost = ProxyHost(); if (proxyHost && UsingHttpProxy()) SetAuthorizationHeader(authCache, nsHttp::Proxy_Authorization, "http", proxyHost, ProxyPort(), nullptr, // proxy has no path mProxyIdent); if (loadFlags & nsIRequest::LOAD_ANONYMOUS) { LOG(("Skipping Authorization header for anonymous load\n")); return NS_OK; } // check if server credentials should be sent nsCAutoString path, scheme; if (NS_SUCCEEDED(GetCurrentPath(path)) && NS_SUCCEEDED(mURI->GetScheme(scheme))) { SetAuthorizationHeader(authCache, nsHttp::Authorization, scheme.get(), Host(), Port(), path.get(), mIdent); } return NS_OK; }
void nsHttpConnectionInfo::SetOriginServer(const nsACString &host, PRInt32 port) { mHost = host; mPort = port == -1 ? DefaultPort() : port; // // build hash key: // // the hash key uniquely identifies the connection type. two connections // are "equal" if they end up talking the same protocol to the same server // and are both used for anonymous or non-anonymous connection only; // anonymity of the connection is setup later from nsHttpChannel::AsyncOpen // where we know we use anonymous connection (LOAD_ANONYMOUS load flag) // const char *keyHost; PRInt32 keyPort; if (mUsingHttpProxy && !mUsingSSL) { keyHost = ProxyHost(); keyPort = ProxyPort(); } else { keyHost = Host(); keyPort = Port(); } mHashKey.AssignLiteral("..."); mHashKey.Append(keyHost); mHashKey.Append(':'); mHashKey.AppendInt(keyPort); if (mUsingHttpProxy) mHashKey.SetCharAt('P', 0); if (mUsingSSL) mHashKey.SetCharAt('S', 1); // NOTE: for transparent proxies (e.g., SOCKS) we need to encode the proxy // type in the hash key (this ensures that we will continue to speak the // right protocol even if our proxy preferences change). if (!mUsingHttpProxy && ProxyHost()) { mHashKey.AppendLiteral(" ("); mHashKey.Append(ProxyType()); mHashKey.Append(')'); } }
nsresult nsHttpChannelAuthProvider::GetAuthorizationMembers(bool proxyAuth, nsCSubstring& scheme, const char*& host, int32_t& port, nsCSubstring& path, nsHttpAuthIdentity*& ident, nsISupports**& continuationState) { if (proxyAuth) { NS_ASSERTION (UsingHttpProxy(), "proxyAuth is true, but no HTTP proxy is configured!"); host = ProxyHost(); port = ProxyPort(); ident = &mProxyIdent; scheme.AssignLiteral("http"); continuationState = &mProxyAuthContinuationState; } else { host = Host(); port = Port(); ident = &mIdent; nsresult rv; rv = GetCurrentPath(path); if (NS_FAILED(rv)) return rv; rv = mURI->GetScheme(scheme); if (NS_FAILED(rv)) return rv; continuationState = &mAuthContinuationState; } return NS_OK; }
void nsHttpConnectionInfo::BuildHashKey() { // // build hash key: // // the hash key uniquely identifies the connection type. two connections // are "equal" if they end up talking the same protocol to the same server // and are both used for anonymous or non-anonymous connection only; // anonymity of the connection is setup later from nsHttpChannel::AsyncOpen // where we know we use anonymous connection (LOAD_ANONYMOUS load flag) // const char *keyHost; int32_t keyPort; if (mUsingHttpProxy && !mUsingConnect) { keyHost = ProxyHost(); keyPort = ProxyPort(); } else { keyHost = Origin(); keyPort = OriginPort(); } // The hashkey has 4 fields followed by host connection info // byte 0 is P/T/. {P,T} for Plaintext/TLS Proxy over HTTP // byte 1 is S/. S is for end to end ssl such as https:// uris // byte 2 is A/. A is for an anonymous channel (no cookies, etc..) // byte 3 is P/. P is for a private browising channel // byte 4 is I/. I is for insecure scheme on TLS for http:// uris // byte 5 is X/. X is for disallow_spdy flag mHashKey.AssignLiteral("......"); mHashKey.Append(keyHost); if (!mNetworkInterfaceId.IsEmpty()) { mHashKey.Append('('); mHashKey.Append(mNetworkInterfaceId); mHashKey.Append(')'); } mHashKey.Append(':'); mHashKey.AppendInt(keyPort); if (!mUsername.IsEmpty()) { mHashKey.Append('['); mHashKey.Append(mUsername); mHashKey.Append(']'); } if (mUsingHttpsProxy) { mHashKey.SetCharAt('T', 0); } else if (mUsingHttpProxy) { mHashKey.SetCharAt('P', 0); } if (mEndToEndSSL) { mHashKey.SetCharAt('S', 1); } // NOTE: for transparent proxies (e.g., SOCKS) we need to encode the proxy // info in the hash key (this ensures that we will continue to speak the // right protocol even if our proxy preferences change). // // NOTE: for SSL tunnels add the proxy information to the cache key. // We cannot use the proxy as the host parameter (as we do for non SSL) // because this is a single host tunnel, but we need to include the proxy // information so that a change in proxy config will mean this connection // is not reused // NOTE: Adding the username and the password provides a means to isolate // keep-alive to the URL bar domain as well: If the username is the URL bar // domain, keep-alive connections are not reused by resources bound to // different URL bar domains as the respective hash keys are not matching. if ((!mUsingHttpProxy && ProxyHost()) || (mUsingHttpProxy && mUsingConnect)) { mHashKey.AppendLiteral(" ("); mHashKey.Append(ProxyType()); mHashKey.Append(':'); mHashKey.Append(ProxyHost()); mHashKey.Append(':'); mHashKey.AppendInt(ProxyPort()); mHashKey.Append(')'); mHashKey.Append('['); mHashKey.Append(ProxyUsername()); mHashKey.Append(':'); const char* password = ProxyPassword(); if (strlen(password) > 0) { nsAutoCString digestedPassword; nsresult rv = SHA256(password, digestedPassword); if (rv == NS_OK) { mHashKey.Append(digestedPassword); } } mHashKey.Append(']'); } if(!mRoutedHost.IsEmpty()) { mHashKey.AppendLiteral(" <ROUTE-via "); mHashKey.Append(mRoutedHost); mHashKey.Append(':'); mHashKey.AppendInt(mRoutedPort); mHashKey.Append('>'); } if (!mNPNToken.IsEmpty()) { mHashKey.AppendLiteral(" {NPN-TOKEN "); mHashKey.Append(mNPNToken); mHashKey.AppendLiteral("}"); } nsAutoCString originAttributes; mOriginAttributes.CreateSuffix(originAttributes); mHashKey.Append(originAttributes); }