diff --git a/net/instaweb/config/measurement_proxy_rewrite_options_manager_test.cc b/net/instaweb/config/measurement_proxy_rewrite_options_manager_test.cc index d76c4a077..009ad7eae 100644 --- a/net/instaweb/config/measurement_proxy_rewrite_options_manager_test.cc +++ b/net/instaweb/config/measurement_proxy_rewrite_options_manager_test.cc @@ -47,7 +47,8 @@ class MeasurementProxyRewriteOptionsManagerTest ProxyInterfaceTestBase::SetUp(); options_manager_ = new MeasurementProxyRewriteOptionsManager( server_context(), "https://www.example.com", "secret"); - url_namer_.reset(new MeasurementProxyUrlNamer()); + url_namer_.reset(new MeasurementProxyUrlNamer( + "https://www.example.com", "secret")); server_context()->SetRewriteOptionsManager(options_manager_); server_context()->set_url_namer(url_namer_.get()); } diff --git a/net/instaweb/rewriter/measurement_proxy_url_namer.cc b/net/instaweb/rewriter/measurement_proxy_url_namer.cc index d7abf157a..bfe052990 100644 --- a/net/instaweb/rewriter/measurement_proxy_url_namer.cc +++ b/net/instaweb/rewriter/measurement_proxy_url_namer.cc @@ -27,7 +27,12 @@ namespace net_instaweb { -MeasurementProxyUrlNamer::MeasurementProxyUrlNamer() { +MeasurementProxyUrlNamer::MeasurementProxyUrlNamer( + const GoogleString& top_origin, const GoogleString& password) + : top_origin_(top_origin), password_(password) { + if (StringPiece(top_origin_).ends_with("/")) { + top_origin_.resize(top_origin.size() - 1); + } } MeasurementProxyUrlNamer::~MeasurementProxyUrlNamer() { diff --git a/net/instaweb/rewriter/measurement_proxy_url_namer_test.cc b/net/instaweb/rewriter/measurement_proxy_url_namer_test.cc index 2dc00a565..9f4afd6d2 100644 --- a/net/instaweb/rewriter/measurement_proxy_url_namer_test.cc +++ b/net/instaweb/rewriter/measurement_proxy_url_namer_test.cc @@ -33,6 +33,7 @@ namespace net_instaweb { class MeasurementProxyUrlNamerTest : public RewriteTestBase { protected: + MeasurementProxyUrlNamerTest() : namer_("http://www.example.com/", "pwd") {} MeasurementProxyUrlNamer namer_; }; diff --git a/net/instaweb/rewriter/public/measurement_proxy_url_namer.h b/net/instaweb/rewriter/public/measurement_proxy_url_namer.h index c6d42fa8b..471a8430b 100644 --- a/net/instaweb/rewriter/public/measurement_proxy_url_namer.h +++ b/net/instaweb/rewriter/public/measurement_proxy_url_namer.h @@ -38,12 +38,10 @@ class RewriteOptions; // before fetching via us (as this doesn't implement Encode() itself). class MeasurementProxyUrlNamer : public UrlNamer { public: - MeasurementProxyUrlNamer(); + MeasurementProxyUrlNamer(const GoogleString& top_origin, + const GoogleString& password); ~MeasurementProxyUrlNamer() override; - // Note: this doesn't deal with the authenication or verification - // of origin or password, the MeasurementProxyRewriteOptionsManager is - // expected to do that. bool Decode(const GoogleUrl& request_url, const RewriteOptions* rewrite_options, GoogleString* decoded) const override; @@ -61,6 +59,9 @@ class MeasurementProxyUrlNamer : public UrlNamer { } private: + GoogleString top_origin_; + GoogleString password_; + DISALLOW_COPY_AND_ASSIGN(MeasurementProxyUrlNamer); }; diff --git a/pagespeed/apache/apache_server_context.cc b/pagespeed/apache/apache_server_context.cc index 5d20f6030..6685ec0fb 100644 --- a/pagespeed/apache/apache_server_context.cc +++ b/pagespeed/apache/apache_server_context.cc @@ -162,7 +162,9 @@ void ApacheServerContext::ChildInit(SystemRewriteDriverFactory* f) { if (global_config()->proxy_all_requests_mode()) { apache_factory_->SetNeedSchedulerThread(); if (global_config()->measurement_proxy_mode()) { - measurement_url_namer_.reset(new MeasurementProxyUrlNamer()); + measurement_url_namer_.reset(new MeasurementProxyUrlNamer( + global_config()->measurement_proxy_root(), + global_config()->measurement_proxy_password())); set_url_namer(measurement_url_namer_.get()); SetRewriteOptionsManager(new MeasurementProxyRewriteOptionsManager( this,