summaryrefslogtreecommitdiffstats
path: root/net/proxy
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
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')
-rw-r--r--net/proxy/proxy_config.cc64
-rw-r--r--net/proxy/proxy_config.h5
-rw-r--r--net/proxy/proxy_script_fetcher.cc31
-rw-r--r--net/proxy/proxy_service.cc11
4 files changed, 108 insertions, 3 deletions
diff --git a/net/proxy/proxy_config.cc b/net/proxy/proxy_config.cc
index 07c1d50..009fcf0 100644
--- a/net/proxy/proxy_config.cc
+++ b/net/proxy/proxy_config.cc
@@ -80,3 +80,67 @@ const ProxyServer* ProxyConfig::ProxyRules::MapSchemeToProxy(
}
} // namespace net
+
+namespace {
+
+// Helper to stringize a ProxyServer.
+std::ostream& operator<<(std::ostream& out,
+ const net::ProxyServer& proxy_server) {
+ if (proxy_server.is_valid())
+ out << proxy_server.ToURI();
+ return out;
+}
+
+// Helper to stringize a ProxyRules.
+std::ostream& operator<<(std::ostream& out,
+ const net::ProxyConfig::ProxyRules& rules) {
+ // Stringize the type enum.
+ std::string type;
+ switch (rules.type) {
+ case net::ProxyConfig::ProxyRules::TYPE_NO_RULES:
+ type = "TYPE_NO_RULES";
+ break;
+ case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME:
+ type = "TYPE_PROXY_PER_SCHEME";
+ break;
+ case net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY:
+ type = "TYPE_SINGLE_PROXY";
+ break;
+ default:
+ type = IntToString(rules.type);
+ break;
+ }
+ return out << " {\n"
+ << " type: " << type << "\n"
+ << " single_proxy: " << rules.single_proxy << "\n"
+ << " proxy_for_http: " << rules.proxy_for_http << "\n"
+ << " proxy_for_https: " << rules.proxy_for_https << "\n"
+ << " proxy_for_ftp: " << rules.proxy_for_ftp << "\n"
+ << " }";
+}
+
+} // namespace
+
+std::ostream& operator<<(std::ostream& out, const net::ProxyConfig& config) {
+ out << "{\n"
+ << " auto_detect: " << config.auto_detect << "\n"
+ << " pac_url: " << config.pac_url << "\n"
+ << " proxy_rules:\n" << config.proxy_rules << "\n"
+ << " proxy_bypass_local_names: " << config.proxy_bypass_local_names
+ << "\n"
+ << " proxy_bypass_list:\n";
+
+ // Print out the proxy bypass list.
+ if (!config.proxy_bypass.empty()) {
+ out << " {\n";
+ std::vector<std::string>::const_iterator it;
+ for (it = config.proxy_bypass.begin();
+ it != config.proxy_bypass.end(); ++it) {
+ out << " " << *it << "\n";
+ }
+ out << " }\n";
+ }
+
+ out << "}";
+ return out;
+}
diff --git a/net/proxy/proxy_config.h b/net/proxy/proxy_config.h
index 5fca8fe..4c3a731 100644
--- a/net/proxy/proxy_config.h
+++ b/net/proxy/proxy_config.h
@@ -5,6 +5,7 @@
#ifndef NET_PROXY_PROXY_CONFIG_H_
#define NET_PROXY_PROXY_CONFIG_H_
+#include <ostream>
#include <string>
#include <vector>
@@ -106,4 +107,8 @@ class ProxyConfig {
} // namespace net
+// Dump a human-readable string representation of the configuration to |out|;
+// used when logging the configuration changes.
+std::ostream& operator<<(std::ostream& out, const net::ProxyConfig& config);
+
#endif // NET_PROXY_PROXY_CONFIG_H_
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);
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 40f4bd3..c8e8a7a 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -397,6 +397,9 @@ void ProxyService::ProcessPendingRequests(PacRequest* recent_req) {
in_progress_fetch_config_id_ = config_.id();
+ LOG(INFO) << "Starting fetch of PAC script " << pac_url
+ << " for config_id=" << in_progress_fetch_config_id_;
+
proxy_script_fetcher_->Fetch(
pac_url, &in_progress_fetch_bytes_, &proxy_script_fetcher_callback_);
return;
@@ -420,6 +423,12 @@ void ProxyService::OnScriptFetchCompletion(int result) {
DCHECK(IsFetchingPacScript());
DCHECK(!resolver_->does_fetch());
+ LOG(INFO) << "Completed PAC script fetch for config_id="
+ << in_progress_fetch_config_id_
+ << " with error " << ErrorToString(result)
+ << ". Fetched a total of " << in_progress_fetch_bytes_.size()
+ << " bytes";
+
// Notify the ProxyResolver of the new script data (will be empty string if
// result != OK).
InitPacThread();
@@ -540,6 +549,8 @@ void ProxyService::UpdateConfig() {
if (latest.Equals(config_))
return;
+ LOG(INFO) << "New proxy configuration was loaded:\n" << latest;
+
config_ = latest;
config_is_bad_ = false;