summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_script_fetcher.cc
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-13 17:32:37 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-13 17:32:37 +0000
commit13a279ed95dc2e5d2f71172594dca1c3901b1322 (patch)
treece274eb858c4c4fdd86e47fb05aba8cf03766aa1 /net/proxy/proxy_script_fetcher.cc
parent6b5f21d8a7f8c0b6b4a689f32afe62fe64d0fa04 (diff)
downloadchromium_src-13a279ed95dc2e5d2f71172594dca1c3901b1322.zip
chromium_src-13a279ed95dc2e5d2f71172594dca1c3901b1322.tar.gz
chromium_src-13a279ed95dc2e5d2f71172594dca1c3901b1322.tar.bz2
Add some LOG(INFO) to help diagnose problems when proxy is not working.
- Dump the proxy configuration to LOG(INFO) each time it changes - Log each attempt at downloading a PAC script. Review URL: http://codereview.chromium.org/67053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13601 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_script_fetcher.cc')
-rw-r--r--net/proxy/proxy_script_fetcher.cc31
1 files changed, 28 insertions, 3 deletions
diff --git a/net/proxy/proxy_script_fetcher.cc b/net/proxy/proxy_script_fetcher.cc
index 22e559ee..a397caa 100644
--- a/net/proxy/proxy_script_fetcher.cc
+++ b/net/proxy/proxy_script_fetcher.cc
@@ -5,6 +5,7 @@
#include "net/proxy/proxy_script_fetcher.h"
#include "base/compiler_specific.h"
+#include "base/logging.h"
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "base/string_util.h"
@@ -27,6 +28,19 @@ int max_response_bytes = 1048576; // 1 megabyte
// Responses exceeding this will fail with ERR_TIMED_OUT.
int max_duration_ms = 300000; // 5 minutes
+// Returns true if |mime_type| is one of the known PAC mime type.
+bool IsPacMimeType(const std::string& mime_type) {
+ static const char * const kSupportedPacMimeTypes[] = {
+ "application/x-ns-proxy-autoconfig",
+ "application/x-javascript-config",
+ };
+ for (size_t i = 0; i < arraysize(kSupportedPacMimeTypes); ++i) {
+ if (LowerCaseEqualsASCII(mime_type, kSupportedPacMimeTypes[i]))
+ return true;
+ }
+ return false;
+}
+
} // namespace
class ProxyScriptFetcherImpl : public ProxyScriptFetcher,
@@ -165,6 +179,7 @@ void ProxyScriptFetcherImpl::OnAuthRequired(URLRequest* request,
AuthChallengeInfo* auth_info) {
DCHECK(request == cur_request_.get());
// TODO(eroman):
+ LOG(WARNING) << "Auth required to fetch PAC script, aborting.";
result_code_ = ERR_NOT_IMPLEMENTED;
request->CancelAuth();
}
@@ -173,6 +188,7 @@ void ProxyScriptFetcherImpl::OnSSLCertificateError(URLRequest* request,
int cert_error,
X509Certificate* cert) {
DCHECK(request == cur_request_.get());
+ LOG(WARNING) << "SSL certificate error when fetching PAC script, aborting.";
// Certificate errors are in same space as net errors.
result_code_ = cert_error;
request->Cancel();
@@ -194,9 +210,6 @@ void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) {
// Require HTTP responses to have a success status code.
if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) {
- // NOTE about mime types: We do not enforce mime types on PAC files.
- // This is for compatibility with {IE 7, Firefox 3, Opera 9.5}
-
// NOTE about status codes: We are like Firefox 3 in this respect.
// {IE 7, Safari 3, Opera 9.5} do not care about the status code.
if (request->GetResponseCode() != 200) {
@@ -204,6 +217,18 @@ void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) {
request->Cancel();
return;
}
+
+ // NOTE about mime types: We do not enforce mime types on PAC files.
+ // This is for compatibility with {IE 7, Firefox 3, Opera 9.5}. We will
+ // however log mismatches to help with debugging.
+ if (logging::GetMinLogLevel() <= logging::LOG_INFO) {
+ std::string mime_type;
+ cur_request_->GetMimeType(&mime_type);
+ if (!!IsPacMimeType(mime_type)) {
+ LOG(INFO) << "Fetched PAC script does not have a proper mime type: "
+ << mime_type;
+ }
+ }
}
ReadBody(request);