From a53fa7f6730aa13061007e988c94f549026d72b9 Mon Sep 17 00:00:00 2001 From: "eroman@chromium.org" Date: Wed, 13 Jan 2010 07:23:32 +0000 Subject: Another tweak to about:net-internals: do a redirect after processing the query arguments. BUG=None TEST=None Review URL: http://codereview.chromium.org/546028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36111 0039d316-1c4b-4281-b951-d872f2087c98 --- .../url_request_view_net_internals_job.cc | 70 ++++++++++++---------- .../url_request_view_net_internals_job.h | 9 ++- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/net/url_request/url_request_view_net_internals_job.cc b/net/url_request/url_request_view_net_internals_job.cc index 7ee7d7f..58aa3d7 100644 --- a/net/url_request/url_request_view_net_internals_job.cc +++ b/net/url_request/url_request_view_net_internals_job.cc @@ -479,23 +479,6 @@ class AllSubSections : public SubSection { } }; -// Returns true if |path| is a subpath for "view-cache". -// If it is, then |key| is assigned the subpath. -bool GetViewCacheKeyFromPath(const std::string path, - std::string* key) { - if (!StartsWithASCII(path, kViewHttpCacheSubPath, true)) - return false; - - if (path.size() > strlen(kViewHttpCacheSubPath) && - path[strlen(kViewHttpCacheSubPath)] != '/') - return false; - - if (path.size() > strlen(kViewHttpCacheSubPath) + 1) - *key = path.substr(strlen(kViewHttpCacheSubPath) + 1); - - return true; -} - bool HandleCommand(const std::string& command, URLRequestContext* context) { if (StartsWithASCII(command, "full-logging-", true)) { bool enable_full_logging = (command == "full-logging-enable"); @@ -578,28 +561,27 @@ bool URLRequestViewNetInternalsJob::GetData(std::string* mime_type, charset->assign("UTF-8"); URLRequestContext* context = request_->context(); - std::string details = url_format_->GetDetails(request_->url()); data->clear(); // Use a different handler for "view-cache/*" subpaths. std::string cache_key; - if (GetViewCacheKeyFromPath(details, &cache_key)) { + if (GetViewCacheKeyForRequest(&cache_key)) { GURL url = url_format_->MakeURL(kViewHttpCacheSubPath + std::string("/")); ViewCacheHelper::GetEntryInfoHTML(cache_key, context, url.spec(), data); return true; } - std::string query; - - // Split out the query parameters. - std::string::size_type query_start = details.find('?'); - if (query_start != std::string::npos) { - if (query_start + 1 < details.size()) - query = details.substr(query_start + 1); - details = details.substr(0, query_start); + // Handle any query arguments as a command request, then redirect back to + // the same URL stripped of query parameters. The redirect happens as part + // of IsRedirectResponse(). + if (request_->url().has_query()) { + ProcessQueryStringCommands(context, request_->url().query()); + return true; } + std::string details = url_format_->GetDetails(request_->url()); + data->append("" "Network internals" "