Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

system-test: retain custom headers #226

Merged
merged 1 commit into from Apr 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -180,7 +180,9 @@ In every server block where pagespeed is enabled add:

# This is a temporary workaround that ensures requests for pagespeed
# optimized resources go to the pagespeed handler.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { }
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/ngx_pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location /ngx_pagespeed_statistics {
Expand Down
10 changes: 10 additions & 0 deletions test/nginx_system_test.sh
Expand Up @@ -1387,4 +1387,14 @@ function check_failures_and_exit() {
exit 0
}

start_test Custom headers remain on resources, but cache should be 1 year.
URL="$TEST_ROOT/compressed/hello_js.custom_ext.pagespeed.ce.HdziXmtLIV.txt"
echo $WGET_DUMP $URL
RESOURCE_HEADERS=$($WGET_DUMP $URL)
check_from "$RESOURCE_HEADERS" egrep -q 'X-Extra-Header: 1'
# The extra header should only be added once, not twice.
check_not_from "$RESOURCE_HEADERS" egrep -q 'X-Extra-Header: 1, 1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but do we need to test for the case where we get

X-Extra-Header: 1
X-Extra-Header: 1

Instead of

 X-Extra-Header: 1, 1

here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Not only should we be checking this, but we're getting it wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check added in: bf14e06

check [ "$(echo "$RESOURCE_HEADERS" | grep -c '^X-Extra-Header: 1')" = 1 ]
check_from "$RESOURCE_HEADERS" egrep -q 'Cache-Control: max-age=31536000'

check_failures_and_exit
10 changes: 10 additions & 0 deletions test/pagespeed_test.conf.template
Expand Up @@ -376,6 +376,10 @@ http {
server_name localhost;
pagespeed FileCachePath "@@FILE_CACHE@@";

location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}

# uncomment the following two lines if you're testing memcached
#pagespeed MemcachedServers "localhost:11211";
#pagespeed MemcachedThreads 1;
Expand Down Expand Up @@ -465,6 +469,12 @@ http {

location /mod_pagespeed_test/compressed/ {
add_header Content-Encoding gzip;

# Even though this is also in the server block it must be repeated here
# because add_header directives are only inherited if you don't define
# more of them. See: http://serverfault.com/questions/400197
add_header X-Extra-Header 1;

types {
text/javascript custom_ext;
}
Expand Down