diff --git a/src/ngx_pagespeed.cc b/src/ngx_pagespeed.cc index f03259525..986abe889 100644 --- a/src/ngx_pagespeed.cc +++ b/src/ngx_pagespeed.cc @@ -410,8 +410,6 @@ ngx_int_t copy_response_headers_to_ngx( continue; } else if (STR_EQ_LITERAL(name, "Transfer-Encoding")) { continue; - } else if (STR_EQ_LITERAL(name, "Server")) { - continue; } u_char* name_s = ngx_pstrdup(r->pool, &name); diff --git a/test/nginx_system_test.sh b/test/nginx_system_test.sh index 20cdd176e..4bcb9fa86 100644 --- a/test/nginx_system_test.sh +++ b/test/nginx_system_test.sh @@ -269,6 +269,8 @@ PSA_JS_LIBRARY_URL_PREFIX="pagespeed_custom_static" # An expected failure can be indicated like: "~In-place resource optimization~" PAGESPEED_EXPECTED_FAILURES=" +~Override server header in resource flow.~ +~Override server header in IPRO flow.~ " # 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. OUT=$($WGET_DUMP "$HOSTNAME/pagespeed_admin/cache?purge=*") check_from "$OUT" fgrep -q "pagespeed EnableCachePurge on;" +start_test Default server header in html flow. +URL=http://headers.example.com/mod_pagespeed_example/ +OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) +# '|| true' in the line below supresses the exit code from grep when there is no +# match in its input (1). +MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true +check [ $MATCHES -eq 1 ] + +start_test Default server header in resource flow. +URL=http://headers.example.com/mod_pagespeed_example/ +URL+=combine_javascript2.js+combine_javascript1.js.pagespeed.jc.0.js +OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) +MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true +check [ $MATCHES -eq 1 ] + +start_test Default server header in IPRO flow. +URL=http://headers.example.com//mod_pagespeed_example/combine_javascript2.js +OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) +MATCHES=$(echo "$OUT" | grep -c "Server: nginx/") || true +check [ $MATCHES -eq 1 ] + +start_test Override server header in html flow. +URL=http://headers.example.com/mod_pagespeed_test/whitespace.html +OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) +MATCHES=$(echo "$OUT" | grep -c "Server: override") || true +check [ $MATCHES -eq 1 ] + +start_test Override server header in resource flow. +URL=http://headers.example.com/mod_pagespeed_test/ +URL+=A.proxy_pass.css.pagespeed.cf.0.css +OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) +MATCHES=$(echo "$OUT" | grep -c "Server: override") || true +check [ $MATCHES -eq 1 ] + +start_test Override server header in IPRO flow. +URL=http://headers.example.com/mod_pagespeed_test/proxy_pass.css +OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) +MATCHES=$(echo "$OUT" | grep -c "Server: override") || true +check [ $MATCHES -eq 1 ] + if $USE_VALGRIND; then # It is possible that there are still ProxyFetches outstanding # at this point in time. Give them a few extra seconds to allow diff --git a/test/pagespeed_test.conf.template b/test/pagespeed_test.conf.template index 72ef10ec8..c7d5e966c 100644 --- a/test/pagespeed_test.conf.template +++ b/test/pagespeed_test.conf.template @@ -1177,6 +1177,22 @@ http { pagespeed EnableFilters rewrite_css; } + server { + listen @@SECONDARY_PORT@@; + listen [::]:@@SECONDARY_PORT@@; + server_name headers.example.com; + root "@@SERVER_ROOT@@"; + pagespeed FileCachePath "@@FILE_CACHE@@_purge"; + pagespeed RewriteLevel CoreFilters; + + pagespeed InPlaceRewriteDeadlineMs -1; + pagespeed LoadFromFile "http://headers.example.com/" + "@@SERVER_ROOT@@/"; + location /mod_pagespeed_test/ { + more_set_headers "Server: overriden"; + } + } + server { listen @@PRIMARY_PORT@@; listen [::]:@@PRIMARY_PORT@@;