options: support StaticAssetPrefix
Backporting this to master for 1.8.31.3. Fixes #705.
This commit is contained in:
@@ -46,9 +46,10 @@ const char kGlobalAdminPath[] = "GlobalAdminPath";
|
|||||||
|
|
||||||
// These options are copied from mod_instaweb.cc, where APACHE_CONFIG_OPTIONX
|
// These options are copied from mod_instaweb.cc, where APACHE_CONFIG_OPTIONX
|
||||||
// indicates that they can not be set at the directory/location level. They set
|
// indicates that they can not be set at the directory/location level. They set
|
||||||
// options in the RewriteDriverFactory, so they do not appear in RewriteOptions.
|
// options in the RewriteDriverFactory, so they're entirely global and do not
|
||||||
// They are not alphabetized on purpose, but rather left in the same order as in
|
// appear in RewriteOptions. They are not alphabetized on purpose, but rather
|
||||||
// mod_instaweb.cc in case we end up needing to compare.
|
// left in the same order as in mod_instaweb.cc in case we end up needing to
|
||||||
|
// compare.
|
||||||
// TODO(oschaaf): this duplication is a short term solution.
|
// TODO(oschaaf): this duplication is a short term solution.
|
||||||
const char* const server_only_options[] = {
|
const char* const server_only_options[] = {
|
||||||
"FetcherTimeoutMs",
|
"FetcherTimeoutMs",
|
||||||
@@ -61,6 +62,7 @@ const char* const server_only_options[] = {
|
|||||||
"MessageBufferSize",
|
"MessageBufferSize",
|
||||||
"NumRewriteThreads",
|
"NumRewriteThreads",
|
||||||
"NumExpensiveRewriteThreads",
|
"NumExpensiveRewriteThreads",
|
||||||
|
"StaticAssetPrefix",
|
||||||
"TrackOriginalContentLength",
|
"TrackOriginalContentLength",
|
||||||
"UsePerVHostStatistics", // TODO(anupama): What to do about "No longer used"
|
"UsePerVHostStatistics", // TODO(anupama): What to do about "No longer used"
|
||||||
"BlockingRewriteRefererUrls",
|
"BlockingRewriteRefererUrls",
|
||||||
@@ -309,8 +311,11 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
|
|||||||
result = ParseAndSetOptionHelper<SystemRewriteDriverFactory>(
|
result = ParseAndSetOptionHelper<SystemRewriteDriverFactory>(
|
||||||
arg, driver_factory,
|
arg, driver_factory,
|
||||||
&SystemRewriteDriverFactory::set_track_original_content_length);
|
&SystemRewriteDriverFactory::set_track_original_content_length);
|
||||||
|
} else if (IsDirective(directive, "StaticAssetPrefix")) {
|
||||||
|
driver_factory->set_static_asset_prefix(arg);
|
||||||
|
result = RewriteOptions::kOptionOk;
|
||||||
} else {
|
} else {
|
||||||
result = ParseAndSetOptionFromName1(directive, args[1], &msg, handler);
|
result = ParseAndSetOptionFromName1(directive, arg, &msg, handler);
|
||||||
}
|
}
|
||||||
} else if (n_args == 3) {
|
} else if (n_args == 3) {
|
||||||
// Short-term special handling, until this moves to common code.
|
// Short-term special handling, until this moves to common code.
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ if [ ! -e "$SYSTEM_TEST_FILE" ] ; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PSA_JS_LIBRARY_URL_PREFIX="pagespeed_static"
|
PSA_JS_LIBRARY_URL_PREFIX="pagespeed_custom_static"
|
||||||
|
|
||||||
# An expected failure can be indicated like: "~In-place resource optimization~"
|
# An expected failure can be indicated like: "~In-place resource optimization~"
|
||||||
PAGESPEED_EXPECTED_FAILURES="
|
PAGESPEED_EXPECTED_FAILURES="
|
||||||
@@ -2204,7 +2204,7 @@ keepalive_test "keepalive-beacon-post.example.com" "/ngx_pagespeed_beacon"\
|
|||||||
|
|
||||||
start_test keepalive with static resources
|
start_test keepalive with static resources
|
||||||
keepalive_test "keepalive-static.example.com"\
|
keepalive_test "keepalive-static.example.com"\
|
||||||
"/pagespeed_static/js_defer.0.js" ""
|
"/pagespeed_custom_static/js_defer.0.js" ""
|
||||||
|
|
||||||
# Test for MaxCombinedCssBytes. The html used in the test, 'combine_css.html',
|
# Test for MaxCombinedCssBytes. The html used in the test, 'combine_css.html',
|
||||||
# has 4 CSS files in the following order.
|
# has 4 CSS files in the following order.
|
||||||
@@ -2239,7 +2239,7 @@ CONNECTION=$(extract_headers $FETCH_UNTIL_OUTFILE | fgrep "Connection:")
|
|||||||
check_not_from "$CONNECTION" fgrep -qi "Keep-Alive, Keep-Alive"
|
check_not_from "$CONNECTION" fgrep -qi "Keep-Alive, Keep-Alive"
|
||||||
check_from "$CONNECTION" fgrep -qi "Keep-Alive"
|
check_from "$CONNECTION" fgrep -qi "Keep-Alive"
|
||||||
|
|
||||||
start_test pagespeed_static defer js served with correct headers.
|
start_test pagespeed_custom_static defer js served with correct headers.
|
||||||
# First, determine which hash js_defer is served with. We need a correct hash
|
# First, determine which hash js_defer is served with. We need a correct hash
|
||||||
# to get it served up with an Etag, which is one of the things we want to test.
|
# to get it served up with an Etag, which is one of the things we want to test.
|
||||||
URL="$HOSTNAME/mod_pagespeed_example/defer_javascript.html?PageSpeed=on&PageSpeedFilters=defer_javascript"
|
URL="$HOSTNAME/mod_pagespeed_example/defer_javascript.html?PageSpeed=on&PageSpeedFilters=defer_javascript"
|
||||||
@@ -2397,6 +2397,49 @@ WGETRC=$OLD_WGETRC
|
|||||||
WGET_ARGS=""
|
WGET_ARGS=""
|
||||||
|
|
||||||
JS_URL="$HOSTNAME/pagespeed_static/js_defer.$HASH.js"
|
JS_URL="$HOSTNAME/pagespeed_static/js_defer.$HASH.js"
|
||||||
|
start_test Request Option Override : Correct values are passed
|
||||||
|
HOST_NAME="http://request-option-override.example.com"
|
||||||
|
OPTS="?ModPagespeed=on"
|
||||||
|
OPTS+="&ModPagespeedFilters=+collapse_whitespace,+remove_comments"
|
||||||
|
OPTS+="&PageSpeedRequestOptionOverride=abc"
|
||||||
|
URL="$HOST_NAME/mod_pagespeed_test/forbidden.html$OPTS"
|
||||||
|
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $URL)"
|
||||||
|
echo wget $URL
|
||||||
|
check_not_from "$OUT" grep -q '<!--'
|
||||||
|
|
||||||
|
start_test Request Option Override : Incorrect values are passed
|
||||||
|
HOST_NAME="http://request-option-override.example.com"
|
||||||
|
OPTS="?ModPagespeed=on"
|
||||||
|
OPTS+="&ModPagespeedFilters=+collapse_whitespace,+remove_comments"
|
||||||
|
OPTS+="&PageSpeedRequestOptionOverride=notabc"
|
||||||
|
URL="$HOST_NAME/mod_pagespeed_test/forbidden.html$OPTS"
|
||||||
|
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $URL)"
|
||||||
|
echo wget $URL
|
||||||
|
check_from "$OUT" grep -q '<!--'
|
||||||
|
|
||||||
|
start_test Request Option Override : Correct values are passed as headers
|
||||||
|
HOST_NAME="http://request-option-override.example.com"
|
||||||
|
OPTS="--header=ModPagespeed:on"
|
||||||
|
OPTS+=" --header=ModPagespeedFilters:+collapse_whitespace,+remove_comments"
|
||||||
|
OPTS+=" --header=PageSpeedRequestOptionOverride:abc"
|
||||||
|
URL="$HOST_NAME/mod_pagespeed_test/forbidden.html"
|
||||||
|
echo wget $OPTS $URL
|
||||||
|
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $OPTS $URL)"
|
||||||
|
check_not_from "$OUT" grep -q '<!--'
|
||||||
|
|
||||||
|
start_test Request Option Override : Incorrect values are passed as headers
|
||||||
|
HOST_NAME="http://request-option-override.example.com"
|
||||||
|
OPTS="--header=ModPagespeed:on"
|
||||||
|
OPTS+=" --header=ModPagespeedFilters:+collapse_whitespace,+remove_comments"
|
||||||
|
OPTS+=" --header=PageSpeedRequestOptionOverride:notabc"
|
||||||
|
URL="$HOST_NAME/mod_pagespeed_test/forbidden.html"
|
||||||
|
echo wget $OPTS $URL
|
||||||
|
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $OPTS $URL)"
|
||||||
|
check_from "$OUT" grep -q '<!--'
|
||||||
|
|
||||||
|
start_test JS gzip headers
|
||||||
|
|
||||||
|
JS_URL="$HOSTNAME/pagespeed_custom_static/js_defer.$HASH.js"
|
||||||
JS_HEADERS=$($WGET -O /dev/null -q -S --header='Accept-Encoding: gzip' \
|
JS_HEADERS=$($WGET -O /dev/null -q -S --header='Accept-Encoding: gzip' \
|
||||||
$JS_URL 2>&1)
|
$JS_URL 2>&1)
|
||||||
check_from "$JS_HEADERS" egrep -qi 'HTTP/1[.]. 200 OK'
|
check_from "$JS_HEADERS" egrep -qi 'HTTP/1[.]. 200 OK'
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ http {
|
|||||||
pagespeed AdminPath /pagespeed_admin;
|
pagespeed AdminPath /pagespeed_admin;
|
||||||
pagespeed GlobalAdminPath /pagespeed_global_admin;
|
pagespeed GlobalAdminPath /pagespeed_global_admin;
|
||||||
|
|
||||||
|
pagespeed StaticAssetPrefix /pagespeed_custom_static/;
|
||||||
|
|
||||||
root "@@SERVER_ROOT@@";
|
root "@@SERVER_ROOT@@";
|
||||||
|
|
||||||
# Block 5a: Decide on Cache-Control header value to use for outgoing
|
# Block 5a: Decide on Cache-Control header value to use for outgoing
|
||||||
|
|||||||
Reference in New Issue
Block a user