From 03ac464839561e97c9275d258212bc9443f25a77 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Mon, 17 Jun 2002 20:49:42 +0000 Subject: [PATCH] Don't send HEAD to FTP servers behind HTTP proxies. Bug 148813, r=bbaetz, sr=darin --- netwerk/base/src/nsURIChecker.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/netwerk/base/src/nsURIChecker.cpp b/netwerk/base/src/nsURIChecker.cpp index 945294fce3b..2ddcc0253a4 100644 --- a/netwerk/base/src/nsURIChecker.cpp +++ b/netwerk/base/src/nsURIChecker.cpp @@ -118,8 +118,21 @@ nsURIChecker::AsyncCheckURI(const nsACString &aURI, // See if it's an http channel, which needs special treatment: nsCOMPtr httpChannel = do_QueryInterface(mChannel); - if (httpChannel) - httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("HEAD")); + if (httpChannel) { + // We can have an HTTP channel that has a non-HTTP URL if + // we're doing FTP via an HTTP proxy, for example. See for + // example bug 148813 + nsCOMPtr channelURI; + mChannel->GetURI(getter_AddRefs(channelURI)); + if (channelURI) { + PRBool isReallyHTTP = PR_FALSE; + channelURI->SchemeIs("http", &isReallyHTTP); + if (!isReallyHTTP) + channelURI->SchemeIs("https", &isReallyHTTP); + if (isReallyHTTP) + httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("HEAD")); + } + } // Hook us up to listen to redirects and the like mChannel->SetNotificationCallbacks(this);