Skip to content

Commit 4bd5b7c

Browse files
committed
Merge pull request apache#997 from pagespeed/jefftk-backport-864-fix
backport apache#864 fix for bugfix release
2 parents 907c57a + a9c292d commit 4bd5b7c

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

src/ngx_pagespeed.cc

-2
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ ngx_int_t copy_response_headers_to_ngx(
410410
continue;
411411
} else if (STR_EQ_LITERAL(name, "Transfer-Encoding")) {
412412
continue;
413-
} else if (STR_EQ_LITERAL(name, "Server")) {
414-
continue;
415413
}
416414

417415
u_char* name_s = ngx_pstrdup(r->pool, &name);

test/nginx_system_test.sh

+42
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ PSA_JS_LIBRARY_URL_PREFIX="pagespeed_custom_static"
269269

270270
# An expected failure can be indicated like: "~In-place resource optimization~"
271271
PAGESPEED_EXPECTED_FAILURES="
272+
~Override server header in resource flow.~
273+
~Override server header in IPRO flow.~
272274
"
273275

274276
# Some tests are flakey under valgrind. For now, add them to the expected failures
@@ -2748,6 +2750,46 @@ start_test Base config has purging disabled. Check error message syntax.
27482750
OUT=$($WGET_DUMP "$HOSTNAME/pagespeed_admin/cache?purge=*")
27492751
check_from "$OUT" fgrep -q "pagespeed EnableCachePurge on;"
27502752

2753+
start_test Default server header in html flow.
2754+
URL=http://headers.example.com/mod_pagespeed_example/
2755+
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
2756+
# '|| true' in the line below supresses the exit code from grep when there is no
2757+
# match in its input (1).
2758+
MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true
2759+
check [ $MATCHES -eq 1 ]
2760+
2761+
start_test Default server header in resource flow.
2762+
URL=http://headers.example.com/mod_pagespeed_example/
2763+
URL+=combine_javascript2.js+combine_javascript1.js.pagespeed.jc.0.js
2764+
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
2765+
MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true
2766+
check [ $MATCHES -eq 1 ]
2767+
2768+
start_test Default server header in IPRO flow.
2769+
URL=http://headers.example.com//mod_pagespeed_example/combine_javascript2.js
2770+
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
2771+
MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true
2772+
check [ $MATCHES -eq 1 ]
2773+
2774+
start_test Override server header in html flow.
2775+
URL=http://headers.example.com/mod_pagespeed_test/whitespace.html
2776+
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
2777+
MATCHES=$(echo "$OUT" | grep -c "Server: override") || true
2778+
check [ $MATCHES -eq 1 ]
2779+
2780+
start_test Override server header in resource flow.
2781+
URL=http://headers.example.com/mod_pagespeed_test/
2782+
URL+=A.proxy_pass.css.pagespeed.cf.0.css
2783+
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
2784+
MATCHES=$(echo "$OUT" | grep -c "Server: override") || true
2785+
check [ $MATCHES -eq 1 ]
2786+
2787+
start_test Override server header in IPRO flow.
2788+
URL=http://headers.example.com/mod_pagespeed_test/proxy_pass.css
2789+
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
2790+
MATCHES=$(echo "$OUT" | grep -c "Server: override") || true
2791+
check [ $MATCHES -eq 1 ]
2792+
27512793
if $USE_VALGRIND; then
27522794
# It is possible that there are still ProxyFetches outstanding
27532795
# at this point in time. Give them a few extra seconds to allow

test/pagespeed_test.conf.template

+16
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,22 @@ http {
11771177
pagespeed EnableFilters rewrite_css;
11781178
}
11791179

1180+
server {
1181+
listen @@SECONDARY_PORT@@;
1182+
listen [::]:@@SECONDARY_PORT@@;
1183+
server_name headers.example.com;
1184+
root "@@SERVER_ROOT@@";
1185+
pagespeed FileCachePath "@@FILE_CACHE@@_purge";
1186+
pagespeed RewriteLevel CoreFilters;
1187+
1188+
pagespeed InPlaceRewriteDeadlineMs -1;
1189+
pagespeed LoadFromFile "http://headers.example.com/"
1190+
"@@SERVER_ROOT@@/";
1191+
location /mod_pagespeed_test/ {
1192+
more_set_headers "Server: overriden";
1193+
}
1194+
}
1195+
11801196
server {
11811197
listen @@PRIMARY_PORT@@;
11821198
listen [::]:@@PRIMARY_PORT@@;

0 commit comments

Comments
 (0)