allow gzipped data to be passed back to the user in psx proxy mode

fixup the logic for accepting gzip
This commit is contained in:
Jeffrey Crowell
2016-08-25 11:12:51 -04:00
parent 3e31b0c5d6
commit fd4fda305d
7 changed files with 39 additions and 5 deletions
+13
View File
@@ -1899,6 +1899,19 @@ ModPagespeedMessagesDomains Allow localhost
ModPagespeedFileCachePath "@@MOD_PAGESPEED_CACHE@@_mpr"
ModPagespeedExperimentalProxyAllRequests on
ModPagespeedExperimentalMeasurementProxy "http://mpr.example.com" secret
ModPagespeedFetchWithGzip on
</VirtualHost>
# For testing measurement proxy things, passthrough.
<VirtualHost localhost:@@APACHE_SECONDARY_PORT@@>
ServerName mprpass.example.com
DocumentRoot "@@APACHE_DOC_ROOT@@"
ModPagespeedFileCachePath "@@MOD_PAGESPEED_CACHE@@_mprpass"
ModPagespeedExperimentalProxyAllRequests on
ModPagespeedExperimentalMeasurementProxy "http://mprpass.example.com" secret
ModPagespeedFetchWithGzip on
ModPagespeedRewriteLevel PassThrough
ModPagespeedInPlaceResourceOptimization off
</VirtualHost>
# For testing how we handle process-scope options.
+2 -4
View File
@@ -518,7 +518,6 @@ bool InstawebHandler::HandleAsProxy() {
}
void InstawebHandler::HandleAsProxyForAll() {
static const char kLoopHeader[] = "X-PageSpeed-Loop";
static const char kLoopValue[] = "MPS";
// Note: we can't use MakeFetch here as we want ProxyInterface to create the
@@ -527,14 +526,13 @@ void InstawebHandler::HandleAsProxyForAll() {
ApacheRequestToRequestHeaders(*request_, request_headers.get());
// Do loop detection.
if (request_headers->HasValue(kLoopHeader, kLoopValue)) {
if (request_headers->HasValue(HttpAttributes::kXPageSpeedLoop, kLoopValue)) {
write_handler_response("Loop detected on fetch in ProxyAllRequests mode; "
"you may need to authorize more domains. ",
request_);
return;
}
request_headers->Add(kLoopHeader, kLoopValue);
request_headers->Add(HttpAttributes::kXPageSpeedLoop, kLoopValue);
SimpleBufferedApacheFetch fetch(request_context_,
request_headers.release(),
server_context_->thread_system(),
+13
View File
@@ -1052,6 +1052,19 @@ if [ "$SECONDARY_HOSTNAME" != "" ]; then
OUT=$($CURL --silent --include --proxy $SECONDARY_HOSTNAME\
http://mpr.example.com/h/b/secret/www.gstatic.com/psa/static/A.0e5d6484d7bf84edf94c17a8d6a6c6de-mobilize.css+0f58e3ef023072001e64bba88abaeeeb-mobilize.css,Mcc.JzQiGpc0_X.css.pagespeed.cf.0slDU6deBr.css)
check_from "$OUT" fgrep -q "psmob-map-button"
start_test Measurement proxy mode passthrough gzip
URL="http://mprpass.example.com/h/b/secret/www.gstatic.com/psa/static/57ea3579bb97c7b4ca6658061d5c765b-mobilize.js"
http_proxy=${SECONDARY_HOSTNAME} fetch_until -gzip $URL "wc -c" 69551 "" -le
start_test Measurement proxy mode rewrite gzip
URL="http://mpr.example.com/h/b/secret/www.gstatic.com/psa/static/57ea3579bb97c7b4ca6658061d5c765b-mobilize.js"
http_proxy=${SECONDARY_HOSTNAME} fetch_until -gzip $URL "wc -c" 65151 "" -le
start_test Measurement proxy mode passthrough nogzip
URL="http://mprpass.example.com/h/b/secret/www.gstatic.com/psa/static/57ea3579bb97c7b4ca6658061d5c765b-mobilize.js"
http_proxy=${SECONDARY_HOSTNAME} fetch_until $URL "wc -c" 288467 "" -ge
start_test Measurement proxy mode rewrite nogzip
URL="http://mpr.example.com/h/b/secret/www.gstatic.com/psa/static/57ea3579bb97c7b4ca6658061d5c765b-mobilize.js"
http_proxy=${SECONDARY_HOSTNAME} fetch_until $URL "wc -c" 241055 "" -ge
fi
start_test Make sure Disallow/Allow overrides work in htaccess hierarchies
+7 -1
View File
@@ -267,7 +267,13 @@ void ProxyInterface::GetRewriteOptionsDone(RequestData* request_data,
// Update request_headers.
// We deal with encodings. So strip the users Accept-Encoding headers.
async_fetch->request_headers()->RemoveAll(HttpAttributes::kAcceptEncoding);
if (!async_fetch->request_headers()->Lookup1(
HttpAttributes::kXPageSpeedLoop)) {
// In proxy mode (mpr) we must pass through the accept encoding to be able
// to tell if the origin server is sending gzipped content when the client
// is requesting it.
async_fetch->request_headers()->RemoveAll(HttpAttributes::kAcceptEncoding);
}
// Note: We preserve the User-Agent and Cookies so that the origin servers
// send us the correct HTML. We will need to consider this for caching HTML.
+1
View File
@@ -275,6 +275,7 @@ bool IsCommaSeparatedField(const StringPiece& name) {
StringCaseEqual(name, HttpAttributes::kCacheControl) ||
StringCaseEqual(name, HttpAttributes::kContentEncoding) ||
StringCaseEqual(name, HttpAttributes::kConnection) ||
StringCaseEqual(name, HttpAttributes::kAcceptEncoding) ||
StringCaseEqual(name, HttpAttributes::kVary)) {
return true;
} else {
+1
View File
@@ -125,6 +125,7 @@ const char HttpAttributes::kXUACompatible[] = "X-UA-Compatible";
const char HttpAttributes::kXPsaSplitConfig[] = "X-PSA-Split-Config";
const char HttpAttributes::kXSendfile[] = "X-Sendfile";
const char HttpAttributes::kXAccelRedirect[] = "X-Accel-Redirect";
const char HttpAttributes::kXPageSpeedLoop[] = "X-PageSpeed-Loop";
const char* HttpStatus::GetReasonPhrase(HttpStatus::Code rc) {
switch (rc) {
+2
View File
@@ -153,6 +153,8 @@ struct HttpAttributes {
// Sendfile type responses.
static const char kXSendfile[];
static const char kXAccelRedirect[];
// PageSpeed Loop detection for proxy mode.
static const char kXPageSpeedLoop[];
// Gets a sorted StringPieceVector containing all the end-to-end headers.
// Any fields listed in here should be ignored during sanitization when they