Compare commits

..

29 Commits

Author SHA1 Message Date
Jeff Kaufman 067764aa92 1.10.33.7 -> 1.11.33.0 2016-03-30 15:27:36 -04:00
Jeff Kaufman 84ab39e8e3 Disable the multiple vary headers test for 1.11 2016-03-30 15:27:36 -04:00
Huibao Lin 2cfbec12c5 For backward compatibility, only allow varying on Accept header for ipro-for-browser.example.com 2016-03-30 14:59:07 -04:00
Huibao Lin 9fd8c6f1bb Add system tests for image format, quality, and response in IPRO 2016-03-30 14:59:07 -04:00
Otto van der Schaaf 1051a90c4e NgxFetch: Log url and error when url parsing fails.
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1148
2016-03-30 14:59:07 -04:00
Kees Spoelstra 21a4a83b77 Strip subresource hints pagespeed automatic system test configuration
Corresponding changes for:
- pull https://github.com/pagespeed/mod_pagespeed/pull/1204
- issue Strip subresource hints #973 https://github.com/pagespeed/mod_pagespeed/issues/973
2016-03-30 14:59:07 -04:00
Otto van der Schaaf 2b4c097d48 vary-header: Emit a single vary header in the IPRO flow
The report from some time ago mentioned three Vary: headers,
but I can now only reproduce two using trunk-tracking plus the
original repro-configuration.

This fix unflags r->gzip_vary as set by the gzip module when PSOL
hands us Vary: Accept-Encoding, to make sure that nginx's core
header filter doesn't append another one.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1064
2016-03-30 14:59:07 -04:00
Jeff Kaufman 181875e80b 1.10.33.6 -> 1.10.33.7 2016-03-28 09:04:30 -04:00
Jeff Kaufman 371293af48 handle additional warnings 2016-03-28 09:04:29 -04:00
Jeff Kaufman ba78a8542b 1.10.33.5 -> 1.10.33.6 2016-03-03 15:02:43 -05:00
Otto van der Schaaf 306cdf358a IPRO: Copy the cache control value to ensure a correct lifetime
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1138
2016-03-03 15:02:05 -05:00
Otto van der Schaaf 8ff08ed7e9 Fix valgrind complaint caused by NgxBaseFetch
We should not use r->connection after we finalize the request.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1100
2016-03-03 14:57:55 -05:00
Otto van der Schaaf fab4aac24e Eliminate CHECK that fails (rarely) during the IPRO lookup.
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1096
2016-03-03 14:57:49 -05:00
Otto van der Schaaf 88e3d48d23 Fix crasher on 404 .pagespeed. resources w/a custom location
- Fix nginx-side flow so we handle .pagespeed. resources ok
  when they will land on a customized 404 internal location.
- Additionally, check for a wiped request context and make sure
  we do not dereference a null pointer, which is what hurt in
  the flow we entered above as the IPRO lookup still was
  generating events while the nginx side request context was
  gone.
- Also, as a preliminary measure, do not check fail when we
  receive a stale event originating from a NgxBaseFetch that
  is no longer associated with our request context.
  Do log a warning so we'll hear about this happening either
  through system test failures or a bug report.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1081
2016-03-03 14:57:40 -05:00
Otto van der Schaaf 4ec7afe5a8 Fix shutdown when ngx_pagespeed is completely disabled.
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1120
2016-02-17 10:19:21 -05:00
Jeffrey Crowell 751f532162 1.10.33.5 is released 2016-02-16 16:48:48 -05:00
Otto van der Schaaf fbde0ace7e Support building ngx_pagespeed as a dynamic module.
As of 1.9.11, nginx supports loading dynamic modules
This change makes us support building ngx_pagespeed.so

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1116
2016-02-16 10:57:37 -05:00
Jeff Kaufman 13e99f631b Merge pull request #1112 from pra85/patch-1
Fix a typo
2016-02-11 13:17:03 -05:00
Jeff Kaufman 1c6c9f1a32 Merge pull request #1114 from PiotrSikora/nginx-1.9.11
Fix build with nginx-1.9.11+.
2016-02-10 15:03:00 -05:00
Piotr Sikora daa6031294 Fix build with nginx-1.9.11+.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-02-10 11:43:44 -08:00
Prayag Verma 5446303610 Fix a typo
`neet` → `need`
2016-02-09 11:30:05 +05:30
Jeffrey Crowell 6c3cc29def 1.10.33.4 is out 2016-02-05 13:11:31 -05:00
Jeffrey Crowell 17e8c7535a Merge pull request #1088 from pagespeed/crowell-reapply744
reapply:  location-header: tweak location header handling
2015-12-31 10:45:40 -05:00
Jeffrey Crowell 01e458ca0d reapply: location-header: tweak location header handling
- Fix potentially sending the location header into PSOL twice.
- Be more thorough when unsetting the location header

Attempts to fix #725

from oschaaf
2015-12-31 10:38:38 -05:00
Jeff Kaufman cd8c45fc86 1.10.33.1 -> 1.10.33.2 2015-12-18 15:04:42 -05:00
Jeff Kaufman 9d6bfad665 Restore dropped fix for #957
@rfnx fixed #957 in acb89a, but this was accidentally merged to master
instead of trunk-tracking.  I checked for this sort of problem as part
of the 1.10 release, but missed this commit.  Restored.

Fixes #1054
2015-12-18 15:04:42 -05:00
Otto van der Schaaf c253c3ba80 log: initialize logging earlier
It turns out to be possible to initialize logging earlier by
grabbing the log from a global ngx_cycle structure.

This makes us start logging earlier, yet loses the
"No threading detected ..." messages both from stderr and
in error.log when nginx initially starts.

With this change, these messages will now be logged as we start
logging earlier:

"
flush
.
"

These originate from SystemCachePath::CacheKey which appends
newlines to the key, and the resulting cache key ends up being
logged. We might want to change that, because the resulting
lines in error.log look weird and might raise questions.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/895
2015-12-17 17:18:18 -05:00
Jeff Kaufman 8c7c8a843a 1.10.33.0 -> 1.10.33.1 2015-12-16 08:13:40 -05:00
Jeff Kaufman bcb1eb1dec release: version 1.9 -> 1.10 2015-12-14 08:27:41 -05:00
22 changed files with 188 additions and 1393 deletions
-66
View File
@@ -1,66 +0,0 @@
language: c++
# Remove broken repo, per: https://github.com/travis-ci/travis-ci/issues/6588
# Undo this once the repo is fixed.
before_install:
- "sudo add-apt-repository --remove 'http://us-central1.gce.archive.ubuntu.com/ubuntu/ main restricted'"
- "sudo add-apt-repository --remove 'http://us-central1.gce.archive.ubuntu.com/ubuntu/ universe'"
- "sudo add-apt-repository --remove 'http://us-central1.gce.archive.ubuntu.com/ubuntu/ multiverse'"
- "sudo add-apt-repository http://archive.ubuntu.com/ubuntu/"
- "sudo add-apt-repository 'http://archive.ubuntu.com/ubuntu/ universe'"
- "sudo add-apt-repository 'http://archive.ubuntu.com/ubuntu/ multiverse'"
- "sudo apt-get -qq update"
install:
- sudo sh -c 'echo "deb http://opensource.wandisco.com/ubuntu precise svn18" >> /etc/apt/sources.list.d/subversion18.list'
- sudo wget -q http://opensource.wandisco.com/wandisco-debian.gpg -O- | sudo apt-key add -
- sudo apt-get update 2>&1 > /dev/null
- mv $TRAVIS_BUILD_DIR ~/ngxpagespeed
- sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip g++ python subversion gperf make devscripts fakeroot git curl netcat-traditional gcc-mozilla clang-3.4 2>&1 > /dev/null
- sudo mv /bin/nc.traditional /usr/bin/nc
- export PATH=/usr/lib/gcc-mozilla/bin:$PATH
- sudo ln -sf /usr/lib/gcc-mozilla/lib/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6
- sudo sh -c 'echo "image/webp webp" >> /etc/mime.types'
- mkdir -p ~/bin
- cd ~/bin
- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
- mkdir ~/mod_pagespeed
- cd ~/mod_pagespeed
- git clone https://github.com/pagespeed/mod_pagespeed.git src
- cd src
- ~/bin/depot_tools/gclient config https://github.com/pagespeed/mod_pagespeed.git --unmanaged --name=$PWD
- ~/bin/depot_tools/gclient sync --force --jobs=1
- cd ~/mod_pagespeed/src/pagespeed/automatic
- make BUILDTYPE=Release -C ../../pagespeed/automatic AR.host="$PWD/../../build/wrappers/ar.sh" AR.target="$PWD/../../build/wrappers/ar.sh" all
- cd ~
- git clone https://github.com/FRiCKLE/ngx_cache_purge.git
- NGX_CACHE_PURGE=$PWD/ngx_cache_purge
- wget https://openresty.org/download/ngx_openresty-1.9.7.2.tar.gz
- tar xzf ngx_openresty-*.tar.gz
- cd ngx_openresty-*/
- ./configure --with-luajit
- make
- NGX_DEVEL_KIT=$(echo $HOME/ngx_openresty-*/build/ngx_devel_kit-*/)
- SET_MISC_MODULE=$(echo $HOME/ngx_openresty-*/build/set-misc-nginx-module-*/)
- HEADERS_MORE_MODULE=$(echo $HOME/ngx_openresty-*/build/headers-more-nginx-module-*/)
- cd ~
- wget https://github.com/nginx/nginx/archive/branches/default.zip
- unzip default.zip
- cd nginx-branches-default
- MOD_PAGESPEED_DIR="$HOME/mod_pagespeed/src" ./auto/configure --add-module=$HOME/ngxpagespeed --add-module="$NGX_CACHE_PURGE" --add-module="$NGX_DEVEL_KIT" --add-module="$SET_MISC_MODULE" --add-module="$HEADERS_MORE_MODULE" --with-ipv6
- make
- sudo make install
script:
- echo "build successful"
- echo "cd ~/ngxpagespeed"
- echo "sudo ./test/run_tests.sh 8050 8051 $HOME/mod_pagespeed/src $HOME/nginx-branches-default/objs selfsigned.modpagespeed.com"
- echo "sudo ./test/run_tests.sh 8050 8051 $HOME/mod_pagespeed $HOME/nginx-branches-default/objs/nginx selfsigned.modpagespeed.com"
sudo: required
compiler:
- gcc
notifications:
email:
- cheesy@google.com
- jefftk@google.com
- morlovich@google.com
- jmarantz@google.com
- huibao@google.com
- jcrowell@google.com
-4
View File
@@ -1,4 +0,0 @@
In a release this file would contain the URL to download the pre-compiled PSOL
binary, but on development branches (like this one) you have to build PSOL from
source yourself. See:
https://github.com/pagespeed/ngx_pagespeed/wiki/Building-PSOL-From-Source
-2
View File
@@ -1,7 +1,5 @@
![ngx_pagespeed](https://lh6.googleusercontent.com/-qufedJIJq7Y/UXEvVYxyYvI/AAAAAAAADo8/JHDFQhs91_c/s401/04_ngx_pagespeed.png)
[![Build Status](https://travis-ci.org/pagespeed/ngx_pagespeed.svg?branch=trunk-tracking)](https://travis-ci.org/pagespeed/ngx_pagespeed)
ngx_pagespeed speeds up your site and reduces page load time by automatically
applying web performance best practices to pages and associated assets (CSS,
JavaScript, images) without requiring you to modify your existing content or
+22 -32
View File
@@ -25,27 +25,18 @@ if [ "$mod_pagespeed_dir" = "unset" ] ; then
if [ ! -e "$mod_pagespeed_dir" ] ; then
echo "ngx_pagespeed: pagespeed optimization library not found:"
psol_binary_url="$(cat $ngx_addon_dir/PSOL_BINARY_URL)"
if [[ "$psol_binary_url" != https://* ]]; then
echo "
This is a development branch of ngx_pagespeed, which means there is no
precompiled PSOL library available to link against. Either build from a
release tag, like latest-beta, or build PSOL from source:
https://github.com/pagespeed/ngx_pagespeed/wiki/Building-PSOL-From-Source"
exit 1
fi
echo "
You need to separately download the pagespeed library:
$ cd $ngx_addon_dir
$ wget $psol_binary_url
$ tar -xzvf $(basename $psol_binary_url) # expands to psol/
Or see the installation instructions:
https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source"
echo ""
echo " You need to separately download the pagespeed library:"
echo ""
echo " $ cd /path/to/ngx_pagespeed"
echo " $ wget https://dl.google.com/dl/page-speed/psol/1.11.33.0.tar.gz"
echo " $ tar -xzvf 1.11.33.0.tar.gz # expands to psol/"
echo ""
echo " Or see the installation instructions:"
echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build"
exit 1
fi
else
build_from_source=true
fi
@@ -89,8 +80,10 @@ ps_maybe_gpp_base=`basename $CC| sed s/gcc/g++/`
ps_maybe_gpp="`dirname $CC`/$ps_maybe_gpp_base"
if [ -n "$NGX_GCC_VER" -a \( -x "$ps_maybe_gpp" \) ]; then
LINK=$ps_maybe_gpp
NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT -lstdc++"
else
pagespeed_libs="-lstdc++"
fi
pagespeed_libs="-lstdc++"
# The compiler needs to know that __sync_add_and_fetch_4 is ok,
# and this requires an instruction that didn't exist on i586 or i386.
@@ -105,8 +98,7 @@ CFLAGS="$CFLAGS $FLAG_MARCH"
# to our libpsol.a
# See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
CFLAGS="$CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
CC_OLD_TEST_FLAGS="$CC_TEST_FLAGS"
CC_TEST_FLAGS="$CC_TEST_FLAGS -D_GLIBCXX_USE_CXX11_ABI=0 --std=c++11"
CC_TEST_FLAGS="$CC_TEST_FLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
case "$NGX_GCC_VER" in
4.8*)
@@ -167,19 +159,17 @@ pagespeed_include="\
$mod_pagespeed_dir/third_party/chromium/src \
$mod_pagespeed_dir/third_party/google-sparsehash/src \
$mod_pagespeed_dir/third_party/google-sparsehash/gen/arch/$os_name/$arch_name/include \
$mod_pagespeed_dir/third_party/grpc/src/include \
$mod_pagespeed_dir/third_party/protobuf/src/src \
$mod_pagespeed_dir/third_party/protobuf/src \
$mod_pagespeed_dir/third_party/re2/src \
$mod_pagespeed_dir/out/$buildtype/obj/gen \
$mod_pagespeed_dir/out/$buildtype/obj/gen/protoc_out/instaweb \
$mod_pagespeed_dir/third_party/apr/src/include \
$mod_pagespeed_dir/third_party/aprutil/src/include \
$mod_pagespeed_dir/third_party/apr/gen/arch/$os_name/$arch_name/include \
$mod_pagespeed_dir/third_party/aprutil/gen/arch/$os_name/$arch_name/include \
$mod_pagespeed_dir/url"
$mod_pagespeed_dir/third_party/aprutil/gen/arch/$os_name/$arch_name/include"
ngx_feature_path="$pagespeed_include"
pagespeed_libs="$psol_binary $pagespeed_libs -lrt -pthread -lm"
pagespeed_libs="$pagespeed_libs $psol_binary -lrt -pthread -lm"
ngx_feature_libs="$pagespeed_libs"
ngx_feature_test="
@@ -206,7 +196,7 @@ ngx_feature_test="
if [ $ngx_found = no ]; then
cat << END
$0: error: module ngx_pagespeed requires the pagespeed optimization library.
Look in $PWD/$NGX_AUTOCONF_ERR for more details.
Look in obj/autoconf.err for more details.
END
exit 1
fi
@@ -296,6 +286,8 @@ if [ -n "$ngx_module_link" ]; then
| sed "s/ngx_pagespeed_etag_filter//" \
| sed "s/ngx_http_range_header_filter_module/ngx_http_range_header_filter_module ngx_pagespeed_etag_filter/")
else
# config.make is not executed for dynamic modules
CFLAGS="$CFLAGS -Wno-c++11-extensions"
if [ "$position_aux" = "true" ] ; then
ngx_module_type=HTTP_AUX_FILTER
ngx_module_order=""
@@ -328,7 +320,7 @@ ngx_feature_libs="-lstdc++"
ngx_feature_test="
#if defined(__clang__) && defined(__GLIBCXX__)
// See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning
// See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning
// for a list of various values of __GLIBCXX__. Note that they're not monotonic
// with respect to version numbers.
#if __GLIBCXX__ == 20120322 || __GLIBCXX__ == 20120614
@@ -355,11 +347,9 @@ if [ $ngx_found = no ]; then
cat << END
$0: error: module ngx_pagespeed requires gcc >= 4.8 or clang >= 3.3.
See https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source for some recommendations.
Look in $PWD/$NGX_AUTOCONF_ERR for more details.
Look in objs/autoconf.err for more details.
END
exit 1
fi
have=NGX_PAGESPEED . auto/have
CC_TEST_FLAGS="$CC_OLD_TEST_FLAGS"
+7 -7
View File
@@ -1,7 +1,7 @@
# Since nginx build system doesn't normally do C++, there is no CXXFLAGS for us
# to touch, and compilers are understandably unhappy with --std=c++11 on C
# files. Hence, we hack the makefile to add it for just our sources.
for ps_src_file in $PS_NGX_SRCS; do
ps_obj_file="$NGX_OBJS/addon/src/`basename $ps_src_file .cc`.o"
echo "$ps_obj_file : CFLAGS += --std=c++11" >> $NGX_MAKEFILE
done
if [ -n "$NGX_CLANG_VER" ]; then
# Chromium headers assume clang is always in C++11 mode. Oblige it.
for ps_src_file in $PS_NGX_SRCS; do
ps_obj_file="$NGX_OBJS/addon/src/`basename $ps_src_file .cc`.o"
echo "$ps_obj_file : CFLAGS += --std=c++11" >> $NGX_MAKEFILE
done
fi
-532
View File
@@ -1,532 +0,0 @@
#!/bin/bash
function usage() {
echo "
Usage: build_ngx_pagespeed.sh [options]
Installs ngx_pagespeed and its dependencies. Can optionally build and install
nginx as well.
Options:
-v, --ngx-pagespeed-version <ngx_pagespeed version>
What version of ngx_pagespeed to build. Valid options include:
* latest-beta
* latest-stable
* a version number, such as 1.11.33.4
If you don't specify a version, defaults to latest-stable.
-n, --nginx-version <nginx version>
What version of nginx to build. If not set, this script only prepares the
ngx_pagespeed module, and expects you to handle including it when you
build nginx.
If you pass in 'latest' then this script scrapes the nginx download page
and attempts to determine the latest version automatically.
-m, --dynamic-module
Build ngx_pagespeed as a dynamic module.
-b, --builddir <directory>
Where to build. Defaults to \$HOME.
-p, --no-deps-check
By default, this script checks for the packages it depends on and tries to
install them. If you have installed dependencies from source or are on a
non-deb non-rpm system, this won't work. In that case, install the
dependencies yourself and pass --no-deps-check.
-d, --dryrun
Don't make any changes to the system, just print what changes you
would have made.
-h, --help
Print this message and exit."
}
# Prints an error message and exits with an error code.
function fail() {
local error_message="$@"
echo "$@" >&2
# Normally I'd use $0 in "usage" here, but since most people will be running
# this via curl, that wouldn't actually give something useful.
echo >&2
echo "For usage information, run this script with --help" >&2
exit 1
}
# Intended to be called as:
# bash <(curl dl.google.com/.../build_ngx_pagespeed.sh) <args>
# If we set -e or -u then users of this script will see it silently exit on
# failure. Instead we need to check the exit status of each command manually.
# The run function handles exit-status checking for system-changing commands.
# Additionally, this allows us to easily have a dryrun mode where we don't
# actually make any changes.
function run() {
if "$DRYRUN"; then
echo "would run $@"
else
if ! "$@"; then
echo "Failure running $@, exiting."
exit 1
fi
fi
}
function redhat_is_installed() {
local package_name="$1"
rpm -qa $package_name | grep -q .
}
function debian_is_installed() {
local package_name="$1"
dpkg -l $package_name | grep ^ii | grep -q .
}
function version_sort() {
# We'd rather use sort -V, but that's not available on Centos 5. This works
# for versions in the form A.B.C.D or shorter, which is enough for our use.
sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g
}
# Compare two numeric versions in the form "A.B.C". Works with version numbers
# having up to four components, since that's enough to handle both nginx (3) and
# ngx_pagespeed (4).
function version_older_than() {
local test_version="$1"
local compare_to="$2"
local older_version=$(echo $@ | tr ' ' '\n' | version_sort | head -n 1)
test "$older_version" != "$compare_to"
}
function determine_latest_nginx_version() {
# Scrape nginx's download page to try to find the most recent nginx version.
nginx_download_url="https://nginx.org/en/download.html"
function report_error() {
fail "
Couldn't automatically determine the latest nginx version: failed to $@
$nginx_download_url"
}
nginx_download_page=$(curl -sS --fail "$nginx_download_url") || \
report_error "download"
download_refs=$(echo "$nginx_download_page" | \
grep -o '/download/nginx-[0-9.]*[.]tar[.]gz') || \
report_error "parse"
versions_available=$(echo "$download_refs" | \
sed -e 's~^/download/nginx-~~' -e 's~\.tar\.gz$~~') || \
report_error "extract versions from"
latest_version=$(echo "$versions_available" | version_sort | tail -n 1) || \
report_error "determine latest version from"
if version_older_than "$latest_version" "1.11.4"; then
fail "
Expected the latest version of nginx to be at least 1.11.4 but found
$latest_version on $nginx_download_url"
fi
echo "$latest_version"
}
# Usage:
# install_dependencies install_pkg_cmd is_pkg_installed_cmd dep1 dep2 ...
#
# install_pkg_cmd is a command to install a dependency
# is_pkg_installed_cmd is a command that returns true if the dependency is
# already installed
# each dependency is a package name
function install_dependencies() {
local install_pkg_cmd="$1"
local is_pkg_installed_cmd="$2"
shift 2
local missing_dependencies=""
for package_name in "$@"; do
if ! $is_pkg_installed_cmd $package_name; then
missing_dependencies+="$package_name "
fi
done
if [ -n "$missing_dependencies" ]; then
echo "Detected that we're missing the following depencencies:"
echo " $missing_dependencies"
echo "Installing them:"
run sudo $install_pkg_cmd $missing_dependencies
fi
}
function gcc_too_old() {
# We need gcc >= 4.8
local gcc_major_version=$(gcc -dumpversion | awk -F. '{print $1}')
if [ "$gcc_major_version" -lt 4 ]; then
return 0 # too old
elif [ "$gcc_major_version" -gt 4 ]; then
return 1 # plenty new
fi
# It's gcc 4.x, check if x >= 8:
local gcc_minor_version=$(gcc -dumpversion | awk -F. '{print $2}')
test "$gcc_minor_version" -lt 8
}
function continue_or_exit() {
local prompt="$1"
read -p "$prompt [Y/n] " yn
if [[ "$yn" == N* || "$yn" == n* ]]; then
echo "Cancelled."
exit 0
fi
}
# If a string is very simple we don't need to quote it. But we should quote
# everything else to be safe.
function needs_quoting() {
echo "$@" | grep -q '[^a-zA-Z0-9./_=-]'
}
function escape_for_quotes() {
echo "$@" | sed -e 's~\\~\\\\~g' -e "s~'~\\\\'~g"
}
function quote_arguments() {
local argument_str=""
for argument in "$@"; do
if [ -n "$argument_str" ]; then
argument_str+=" "
fi
if needs_quoting "$argument"; then
argument="'$(escape_for_quotes "$argument")'"
fi
argument_str+="$argument"
done
echo "$argument_str"
}
function build_ngx_pagespeed() {
getopt --test
if [ "$?" != 4 ]; then
# Even Centos 5 and Ubuntu 10 LTS have new-style getopt, so I don't expect
# this to be hit in practice on systems that are actually able to run
# PageSpeed.
fail "Your version of getopt is too old. Exiting with no changes made."
fi
opts=$(getopt -o v:n:mb:pdh \
--longoptions ngx-pagespeed-version:,nginx-version:,dynamic-module \
--longoptions buildir:,no-deps-check,dryrun,help \
-n "$(basename "$0")" -- "$@")
if [ $? != 0 ]; then
usage
exit 1
fi
eval set -- "$opts"
NPS_VERSION="latest-stable"
NGINX_VERSION=""
BUILDDIR="$HOME"
DO_DEPS_CHECK=true
DRYRUN=false
DYNAMIC_MODULE=false
while true; do
case "$1" in
-v | --ngx-pagespeed-version) shift
NPS_VERSION="$1"
shift
;;
-n | --nginx-version) shift
NGINX_VERSION="$1"
shift
;;
-m | --dynamic-module) shift
DYNAMIC_MODULE=true
;;
-b | --builddir) shift
BUILDDIR="$1"
shift
;;
-p | --no-deps-check) shift
DO_DEPS_CHECK=false
;;
-d | --dryrun) shift
DRYRUN="true"
;;
-h | --help) shift
usage
exit 0
;;
--) shift
break
;;
*)
echo "Invalid argument: $1"
usage
exit 1
;;
esac
done
if [ ! -d "$BUILDDIR" ]; then
fail "Told to build in $BUILDDIR, but that directory doesn't exist."
fi
if [ "$NGINX_VERSION" = "latest" ]; then
# When this function fails it prints the debugging information needed first
# to stderr.
NGINX_VERSION=$(determine_latest_nginx_version) || exit 1
fi
if "$DYNAMIC_MODULE"; then
# Check that ngx_pagespeed and nginx are recent enough to support dynamic
# modules.
if version_older_than "$NPS_VERSION" "1.10.33.5"; then
fail "
You're trying to build ngx_pagespeed $NPS_VERSION as a dynamic module, but
ngx_pagespeed didn't add support for dynamic modules until 1.10.33.5."
fi
if [ ! -z "NGINX_VERSION" ]; then
if version_older_than "$NGINX_VERSION" "1.9.13"; then
fail "
You're trying to build nginx $NGINX_VERSION as a dynamic module but nginx didn't
add support for dynamic modules in a way compatible with ngx_pagespeed until
1.9.13."
fi
fi
fi
if "$DRYRUN"; then
TEMPDIR="/tmp/output-of-mktemp"
else
TEMPDIR=$(mktemp -d)
function cleanup_tempdir {
rm -rf "$TEMPDIR"
}
trap cleanup_tempdir EXIT
fi
extra_flags=()
# Now make sure our dependencies are installed.
if "$DO_DEPS_CHECK"; then
if [ -f /etc/debian_version ]; then
echo "Detected debian-based distro."
install_dependencies "apt-get install" debian_is_installed \
"build-essential zlib1g-dev libpcre3 libpcre3-dev unzip"
if gcc_too_old; then
if [ ! -e /usr/lib/gcc-mozilla/bin/gcc ]; then
echo "Detected that gcc is older than 4.8. Installing gcc-mozilla"
echo "which installs gcc-4.8 into /usr/lib/gcc-mozilla/ and doesn't"
echo "affect your global gcc installation."
run sudo apt-get install gcc-mozilla
fi
extra_flags=("--with-cc=/usr/lib/gcc-mozilla/bin/gcc" \
"--with-ld-opt=-static-libstdc++")
fi
elif [ -f /etc/redhat-release ]; then
echo "Detected redhat-based distro."
install_dependencies "yum install" redhat_is_installed \
"gcc-c++ pcre-devel zlib-devel make unzip wget"
if gcc_too_old; then
if [ ! -e /opt/rh/devtoolset-2/root/usr/bin/gcc ]; then
redhat_major_version=$(
cat /etc/redhat-release | grep -o -E '[0-9]+' | head -n 1)
if [ "$redhat_major_version" == 5 ]; then
slc_version=5
elif [ "$redhat_major_version" == 6 ]; then
slc_version=6
else
fail "
Unexpected major version $redhat_major_version in /etc/redhat-release:
$(cat /etc/redhat-release) Expected 5 or 6."
fi
echo "Detected that gcc is older than 4.8. Scientific Linux provides"
echo "a gcc package that installs gcc-4.8 into /opt/ and doesn't"
echo "affect your global gcc installation."
slc_key="https://linux.web.cern.ch/linux/scientific6/docs/repository/"
slc_key+="cern/slc6X/i386/RPM-GPG-KEY-cern"
slc_key_out="$TEMPDIR/RPM-GPG-KEY-cern"
run sudo wget "$slc_key" -O "$slc_key_out"
run sudo rpm --import "$slc_key_out"
repo_fname="/etc/yum.repos.d/slc${slc_version}-devtoolset.repo"
if [ -e "$repo_fname" ]; then
fail "Expected $repo_fname not to exist; aborting."
fi
repo_url="https://linux.web.cern.ch/linux/scientific${slc_version}/"
repo_url+="/docs/repository/cern/devtoolset/"
repo_url+="slc${slc_version}-devtoolset.repo"
run sudo wget -O "$repo_fname" "$repo_url"
run sudo yum install devtoolset-2-gcc-c++ devtoolset-2-binutils
fi
extra_flags=("--with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc")
fi
else
fail "
This doesn't appear to be a deb-based distro or an rpm-based one. Not going to
be able to install dependencies. Please install dependencies manually and rerun
with --depsinstalled."
fi
echo "Dependencies are all set."
else
echo "Not checking whether dependencies are installed."
fi
function delete_if_already_exists() {
if "$DRYRUN"; then return; fi
local directory="$1"
if [ -d "$directory" ]; then
if [ ${#directory} -lt 8 ]; then
fail "
Not deleting $directory; name is suspiciously short. Something is wrong."
exit 1
fi
continue_or_exit "OK to delete $directory?"
run rm -rf "$directory"
fi
}
nps_baseurl="https://github.com/pagespeed/ngx_pagespeed/archive"
# In general, the zip github builds for tag foo unzips to ngx_pagespeed-foo,
# but it looks like they special case vVERSION tags to ngx_pagespeed-VERSION.
if [[ "$NPS_VERSION" =~ ^[0-9]*[.][0-9]*[.][0-9]*[.][0-9]*$ ]]; then
# We've been given a numeric version number. This has an associated tag in
# the form vVERSION-beta.
nps_url_fname="v${NPS_VERSION}-beta"
nps_downloaded_fname="ngx_pagespeed-${NPS_VERSION}-beta"
else
# We've been given a tag name, like latest-beta. Download that directly.
nps_url_fname="$NPS_VERSION"
nps_downloaded_fname="ngx_pagespeed-${NPS_VERSION}"
fi
nps_downloaded="$TEMPDIR/$nps_downloaded_fname.zip"
run wget "$nps_baseurl/$nps_url_fname.zip" -O "$nps_downloaded"
nps_module_dir="$BUILDDIR/$nps_downloaded_fname"
delete_if_already_exists "$nps_module_dir"
echo "Extracting ngx_pagespeed..."
run unzip -q "$nps_downloaded" -d "$BUILDDIR"
run cd "$nps_module_dir"
# Now we need to figure out what precompiled version of PSOL to build
# ngx_pagespeed against.
if "$DRYRUN"; then
psol_url="https://psol.example.com/cant-get-psol-version-in-dry-run.tar.gz"
elif [ -e PSOL_BINARY_URL ]; then
# Releases after 1.11.33.4 there is a PSOL_BINARY_URL file that tells us
# where to look.
psol_url="$(cat PSOL_BINARY_URL)"
if [[ "$psol_url" != https://* ]]; then
fail "Got bad psol binary location information: $psol_url"
fi
else
# For past releases we have to grep it from the config file. The url has
# always looked like this, and the config file has contained it since before
# we started tagging our ngx_pagespeed releases.
psol_url="$(
grep -o "https://dl.google.com/dl/page-speed/psol/[0-9.]*.tar.gz" config)"
if [ -z "$psol_url" ]; then
fail "Couldn't find PSOL url in $PWD/config"
fi
fi
run wget "$psol_url"
echo "Extracting PSOL..."
run tar -xzf $(basename "$psol_url") # extracts to psol/
if "$DYNAMIC_MODULE"; then
add_module="--add-dynamic-module=$nps_module_dir"
else
add_module="--add-module=$nps_module_dir"
fi
configure_args=("$add_module" "${extra_flags[@]}")
echo
if [ -z "$NGINX_VERSION" ]; then
# They didn't specify an nginx version, so we're just preparing the
# module for them to install.
echo "ngx_pagespeed is ready to be built against nginx."
echo "When running ./configure pass in:"
echo " $(quote_arguments "${configure_args[@]}")"
if [ ${#extra_flags[@]} -eq 0 ]; then
echo "If this is for integration with an already-built nginx, make sure"
echo "to include any other arguments you originally passed to ./configure"
echo "You can see these with 'nginx -V'."
else
echo "Note: because we need to set $(quote_arguments "${extra_flags[@]}")"
echo "on this platform, if you want to integrate ngx_pagespeed with an"
echo "already-built nginx you're going to need to rebuild your nginx with"
echo "those flags set."
fi
else
# Download and build nginx.
nginx_leaf="nginx-${NGINX_VERSION}.tar.gz"
nginx_fname="$TEMPDIR/$nginx_leaf"
run wget "http://nginx.org/download/$nginx_leaf" -O "$nginx_fname"
nginx_dir="$BUILDDIR/nginx-${NGINX_VERSION}/"
delete_if_already_exists "$nginx_dir"
echo "Extracting nginx..."
run tar -xzf "$nginx_fname" --directory "$BUILDDIR"
"$DRYRUN" || cd "$nginx_dir"
configure=("./configure" "${configure_args[@]}")
echo "About to build nginx. Do you have any additional ./configure"
echo "arguments you would like to set? For example, if you would like"
echo "to build nginx with https support give --with-http_ssl_module"
echo "If you don't have any, just press enter."
read -p "> " additional_configure_args
if [ -n "$additional_configure_args" ]; then
# Split additional_configure_args respecting any internal quotation.
# Otherwise things like --with-cc-opt='-foo -bar' won't work.
eval additional_configure_args=("$additional_configure_args")
configure=("${configure[@]}" "${additional_configure_args[@]}")
fi
echo "About to configure nginx with:"
echo " $(quote_arguments "${configure[@]}")"
continue_or_exit "Does this look right?"
run "${configure[@]}"
continue_or_exit "Build nginx?"
run make
continue_or_exit "Install nginx?"
run sudo make install
echo
if "$DYNAMIC_MODULE"; then
echo "Nginx installed with ngx_pagespeed support available as a"
echo "loadable module."
echo
echo "To load the ngx_pagespeed module, you'll need to add:"
echo " load_module \"modules/ngx_pagespeed.so\";"
echo "at the top of your main nginx configuration file."
else
echo "Nginx installed with ngx_pagespeed support compiled-in."
fi
echo
echo "If this is a new installation you probably need an init script to"
echo "manage starting and stopping the nginx service. See:"
echo " http://wiki.nginx.org/InitScripts"
echo
echo "You'll also need to configure ngx_pagespeed if you haven't yet:"
echo " https://developers.google.com/speed/pagespeed/module/configuration"
fi
"$DRYRUN" && echo "[this was a dry run; your system is unchanged]"
}
# Start running things from a call at the end so if this script is executed
# after a partial download it doesn't do anything.
build_ngx_pagespeed "$@"
+7 -33
View File
@@ -12,20 +12,17 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: jefftk@google.com (Jeff Kaufman)
*/
#include "ngx_pagespeed.h" // Must come first, see comments in CollectHeaders.
// Author: jefftk@google.com (Jeff Kaufman)
#include <unistd.h> //for usleep
#include "ngx_base_fetch.h"
#include "ngx_event_connection.h"
#include "ngx_list_iterator.h"
#include "net/instaweb/rewriter/public/rewrite_driver.h"
#include "net/instaweb/rewriter/public/rewrite_options.h"
#include "ngx_pagespeed.h"
#include "net/instaweb/rewriter/public/rewrite_stats.h"
#include "pagespeed/kernel/base/google_message_handler.h"
#include "pagespeed/kernel/base/message_handler.h"
@@ -41,19 +38,14 @@ const char kDone = 'D';
NgxEventConnection* NgxBaseFetch::event_connection = NULL;
int NgxBaseFetch::active_base_fetches = 0;
NgxBaseFetch::NgxBaseFetch(StringPiece url,
ngx_http_request_t* r,
NgxBaseFetch::NgxBaseFetch(ngx_http_request_t* r,
NgxServerContext* server_context,
const RequestContextPtr& request_ctx,
PreserveCachingHeaders preserve_caching_headers,
NgxBaseFetchType base_fetch_type,
const RewriteOptions* options)
NgxBaseFetchType base_fetch_type)
: AsyncFetch(request_ctx),
url_(url.data(), url.size()),
request_(r),
server_context_(server_context),
options_(options),
need_flush_(false),
done_called_(false),
last_buf_sent_(false),
references_(2),
@@ -228,11 +220,8 @@ ngx_int_t NgxBaseFetch::CopyBufferToNginx(ngx_chain_t** link_ptr) {
return NGX_AGAIN;
}
int rc = string_piece_to_buffer_chain(request_->pool, buffer_, link_ptr,
done_called_ /* send_last_buf */,
need_flush_);
need_flush_ = false;
int rc = string_piece_to_buffer_chain(
request_->pool, buffer_, link_ptr, done_called_ /* send_last_buf */);
if (rc != NGX_OK) {
return rc;
}
@@ -260,13 +249,6 @@ ngx_int_t NgxBaseFetch::CollectAccumulatedWrites(ngx_chain_t** link_ptr) {
}
ngx_int_t NgxBaseFetch::CollectHeaders(ngx_http_headers_out_t* headers_out) {
// nginx defines _FILE_OFFSET_BITS to 64, which changes the size of off_t.
// If a standard header is accidentally included before the nginx header,
// on a 32-bit system off_t will be 4 bytes and we don't assign all the
// bits of content_length_n. Sanity check that did not happen.
// This could use static_assert, but this file is not built with --std=c++11.
bool sanity_check_off_t[sizeof(off_t) == 8 ? 1 : -1] __attribute__ ((unused));
const ResponseHeaders* pagespeed_headers = response_headers();
if (content_length_known()) {
@@ -317,9 +299,6 @@ void NgxBaseFetch::HandleHeadersComplete() {
}
bool NgxBaseFetch::HandleFlush(MessageHandler* handler) {
Lock();
need_flush_ = true;
Unlock();
RequestCollection(kFlush); // A new part of the response body is available
return true;
}
@@ -352,9 +331,4 @@ void NgxBaseFetch::HandleDone(bool success) {
DecrefAndDeleteIfUnreferenced();
}
bool NgxBaseFetch::IsCachedResultValid(const ResponseHeaders& headers) {
return OptionsAwareHTTPCacheCallback::IsCacheValid(
url_, *options_, request_context(), headers);
}
} // namespace net_instaweb
+3 -14
View File
@@ -43,9 +43,6 @@
// events it handles.
//
// When the last reference is dropped, this class will delete itself.
//
// TODO(jmarantz): consider sharing the cache-invalidation infrastructure
// with ApacheFetch, using a common base class.
#ifndef NGX_BASE_FETCH_H_
#define NGX_BASE_FETCH_H_
@@ -62,7 +59,6 @@ extern "C" {
#include "ngx_server_context.h"
#include "net/instaweb/http/public/async_fetch.h"
#include "net/instaweb/rewriter/public/rewrite_options.h"
#include "pagespeed/kernel/base/string.h"
#include "pagespeed/kernel/http/headers.h"
@@ -78,12 +74,10 @@ enum NgxBaseFetchType {
class NgxBaseFetch : public AsyncFetch {
public:
NgxBaseFetch(StringPiece url, ngx_http_request_t* r,
NgxServerContext* server_context,
NgxBaseFetch(ngx_http_request_t* r, NgxServerContext* server_context,
const RequestContextPtr& request_ctx,
PreserveCachingHeaders preserve_caching_headers,
NgxBaseFetchType base_fetch_type,
const RewriteOptions* options);
NgxBaseFetchType base_fetch_type);
virtual ~NgxBaseFetch();
// Statically initializes event_connection, require for PSOL and nginx to
@@ -131,8 +125,6 @@ class NgxBaseFetch : public AsyncFetch {
ngx_http_request_t* request() { return request_; }
NgxBaseFetchType base_fetch_type() { return base_fetch_type_; }
bool IsCachedResultValid(const ResponseHeaders& headers) override;
private:
virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler);
virtual bool HandleFlush(MessageHandler* handler);
@@ -160,16 +152,13 @@ class NgxBaseFetch : public AsyncFetch {
int DecrefAndDeleteIfUnreferenced();
static NgxEventConnection* event_connection;
// Live count of NgxBaseFetch instances that are currently in use.
static int active_base_fetches;
GoogleString url_;
ngx_http_request_t* request_;
GoogleString buffer_;
NgxServerContext* server_context_;
const RewriteOptions* options_;
bool need_flush_;
bool done_called_;
bool last_buf_sent_;
// How many active references there are to this fetch. Starts at two,
+2 -2
View File
@@ -940,8 +940,8 @@ void NgxFetch::FixUserAgent() {
user_agent += "NgxNativeFetcher";
}
GoogleString version = StrCat(
" (", kModPagespeedSubrequestUserAgent,
"/" MOD_PAGESPEED_VERSION_STRING "-" LASTCHANGE_STRING ")");
" ", kModPagespeedSubrequestUserAgent,
"/" MOD_PAGESPEED_VERSION_STRING "-" LASTCHANGE_STRING);
if (!StringPiece(user_agent).ends_with(version)) {
user_agent += version;
}
+1 -1
View File
@@ -97,6 +97,7 @@ void NgxMessageHandler::MessageSImpl(MessageType type,
} else {
GoogleMessageHandler::MessageSImpl(type, message);
}
// Prepare a log message for the SharedCircularBuffer only.
AddMessageToBuffer(type, message);
}
@@ -110,7 +111,6 @@ void NgxMessageHandler::FileMessageSImpl(
} else {
GoogleMessageHandler::FileMessageSImpl(type, file, line, message);
}
AddMessageToBuffer(type, file, line, message);
}
} // namespace net_instaweb
+41 -143
View File
@@ -124,7 +124,7 @@ char* string_piece_to_pool_string(ngx_pool_t* pool, StringPiece sp) {
// (potentially) longer string to nginx and want it to take ownership.
ngx_int_t string_piece_to_buffer_chain(
ngx_pool_t* pool, StringPiece sp, ngx_chain_t** link_ptr,
bool send_last_buf, bool send_flush) {
bool send_last_buf) {
// Below, *link_ptr will be NULL if we're starting the chain, and the head
// chain link.
*link_ptr = NULL;
@@ -198,9 +198,6 @@ ngx_int_t string_piece_to_buffer_chain(
CHECK(tail_link != NULL);
if (send_flush) {
tail_link->buf->flush = true;
}
if (send_last_buf) {
tail_link->buf->last_buf = true;
}
@@ -288,8 +285,7 @@ ngx_int_t ps_base_fetch_handler(ngx_http_request_t* r) {
if (!status_ok && (ctx->base_fetch->base_fetch_type() != kHtmlTransform
&& ctx->base_fetch->base_fetch_type() != kIproLookup)) {
ps_release_base_fetch(ctx);
ngx_http_filter_finalize_request(r, NULL, status_code);
return NGX_DONE;
return ngx_http_filter_finalize_request(r, NULL, status_code);
}
if (ctx->preserve_caching_headers != kDontPreserveHeaders) {
@@ -426,32 +422,6 @@ ngx_int_t ps_set_cache_control(ngx_http_request_t* r, char* cache_control) {
return NGX_OK;
}
// Returns false if the header wasn't found. Otherwise sets cache_control and
// returns true;
bool ps_get_cache_control(ngx_http_request_t* r, GoogleString* cache_control) {
// Use headers_out.cache_control instead of looking for Cache-Control in
// headers_out.headers, because if an upstream sent multiple Cache-Control
// headers they're already combined in headers_out.cache_control.
auto ccp = static_cast<ngx_table_elt_t**>(r->headers_out.cache_control.elts);
if (ccp == nullptr) {
return false; // Header not present.
}
bool first_segment = true;
for (ngx_uint_t i = 0; i < r->headers_out.cache_control.nelts; i++) {
if (ccp[i]->hash == 0) {
continue; // Elements with a hash of 0 are marked as excluded.
}
if (first_segment) {
first_segment = false;
} else {
cache_control->append(", ");
}
cache_control->append(reinterpret_cast<char*>(ccp[i]->value.data),
ccp[i]->value.len);
}
return true;
}
template<class Headers>
void copy_headers_from_table(const ngx_list_t &from, Headers* to) {
// Standard nginx idiom for iterating over a list. See ngx_list.h
@@ -496,8 +466,7 @@ void copy_response_headers_from_ngx(const ngx_http_request_t* r,
// When we don't have a date header, set one with the current time.
if (headers->Lookup1(HttpAttributes::kDate) == NULL) {
PosixTimer timer;
headers->SetDate(timer.NowMs());
headers->SetDate(ngx_current_msec);
}
// TODO(oschaaf): ComputeCaching should be called in setupforhtml()?
@@ -713,13 +682,6 @@ char* ps_main_configure(ngx_conf_t* cf, ngx_command_t* cmd, void* conf);
char* ps_srv_configure(ngx_conf_t* cf, ngx_command_t* cmd, void* conf);
char* ps_loc_configure(ngx_conf_t* cf, ngx_command_t* cmd, void* conf);
// We want NGX_CONF_MULTI for some very old versions:
// https://github.com/pagespeed/ngx_pagespeed/commit/66f1b9aa
// but it's gone in recent revisions, so provide a compat #define if needed
#ifndef NGX_CONF_MULTI
#define NGX_CONF_MULTI 0
#endif
// TODO(jud): Verify that all the offsets should be NGX_HTTP_SRV_CONF_OFFSET and
// not NGX_HTTP_LOC_CONF_OFFSET or NGX_HTTP_MAIN_CONF_OFFSET.
ngx_command_t ps_commands[] = {
@@ -885,14 +847,14 @@ char* ps_configure(ngx_conf_t* cf,
cfg_m->driver_factory->thread_system());
}
ProcessScriptVariablesMode script_mode =
dynamic_cast<NgxRewriteDriverFactory*>(cfg_m->driver_factory)
->process_script_variables();
if (script_mode != ProcessScriptVariablesMode::kOff) {
bool process_script_variables = dynamic_cast<NgxRewriteDriverFactory*>(
cfg_m->driver_factory)->process_script_variables();
if (process_script_variables) {
// To be able to use '$', we map '$ps_dollar' to '$' via a script variable.
ngx_str_t name = ngx_string("ps_dollar");
ngx_http_variable_t* var =
ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGEABLE);
ngx_http_variable_t* var = ngx_http_add_variable(
cf, &name, NGX_HTTP_VAR_CHANGEABLE);
if (var == NULL) {
return const_cast<char*>(
@@ -903,7 +865,7 @@ char* ps_configure(ngx_conf_t* cf,
const char* status = (*options)->ParseAndSetOptions(
args, n_args, cf->pool, handler, cfg_m->driver_factory, option_scope, cf,
script_mode);
process_script_variables);
// nginx expects us to return a string literal but doesn't mark it const.
return const_cast<char*>(status);
@@ -1124,20 +1086,9 @@ char* ps_merge_srv_conf(ngx_conf_t* cf, void* parent, void* child) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
cfg_m->driver_factory->SetMainConf(parent_cfg_s->options);
cfg_m->driver_factory->set_main_conf(parent_cfg_s->options);
cfg_s->server_context = cfg_m->driver_factory->MakeNgxServerContext(
"dummy_hostname", dummy_port);
#if (NGX_HTTP_V2)
// Save the variable index of the "http2" variable, so we can use it
// at request time to lookup whether that's on. We do this conditionally
// since NGINX will complain to the user (at [emerg] level!) if it doesn't
// know about it.
ngx_str_t name = ngx_string("http2");
cfg_s->server_context->set_ngx_http2_variable_index(
ngx_http_get_variable_index(cf, &name));
#endif
// The server context sets some options when we call global_options(). So
// let it do that, then merge in options we got from the config file.
// Once we do that we're done with cfg_s->options.
@@ -1333,9 +1284,6 @@ ngx_int_t ps_decline_request(ngx_http_request_t* r) {
r->count++;
r->phase_handler++;
//restore read_event_handler to what it was in ps_async_wait_response
r->read_event_handler = ngx_http_block_reading;
r->write_event_handler = ngx_http_core_run_phases;
ngx_http_core_run_phases(r);
ngx_http_run_posted_requests(r->connection);
@@ -1347,13 +1295,6 @@ ngx_int_t ps_async_wait_response(ngx_http_request_t* r) {
CHECK(ctx != NULL);
r->count++;
// While we wait for PSOL to complete an async operation, there is a chance
// that the underlying connection gets closed, or a http/2 RST_STREAM is
// received before the async operation completes. In that case we don't want
// to continue processing this flow. So we override the requests's read event
// handler with one that will make nginx abort request processing and execute
// our cleanup handlers instead of resuming request processing.
r->read_event_handler = ngx_http_test_reading;
r->write_event_handler = ngx_http_request_empty_handler;
ps_set_buffered(r, true);
// We don't need to add a timer here, as it will be set by nginx.
@@ -1640,12 +1581,10 @@ void ps_release_base_fetch(ps_request_ctx_t* ctx) {
}
// TODO(chaizhenhua): merge into NgxBaseFetch ctor
void ps_create_base_fetch(StringPiece url,
ps_request_ctx_t* ctx,
RequestContextPtr request_context,
RequestHeaders* request_headers,
NgxBaseFetchType type,
const RewriteOptions* options) {
void ps_create_base_fetch(ps_request_ctx_t* ctx,
RequestContextPtr request_context,
RequestHeaders* request_headers,
NgxBaseFetchType type) {
CHECK(ctx->base_fetch == NULL) << "Pre-existing base fetch!";
ngx_http_request_t* r = ctx->r;
@@ -1655,9 +1594,9 @@ void ps_create_base_fetch(StringPiece url,
// it, and call Done() on the associated parent (Proxy or Resource) fetch. If
// we fail before creating the associated fetch then we need to call Done() on
// the BaseFetch ourselves.
ctx->base_fetch = new NgxBaseFetch(url, r, cfg_s->server_context, request_context,
ctx->preserve_caching_headers, type,
options);
ctx->base_fetch = new NgxBaseFetch(r, cfg_s->server_context,
request_context,
ctx->preserve_caching_headers, type);
ctx->base_fetch->SetRequestHeadersTakingOwnership(request_headers);
}
@@ -1879,7 +1818,6 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
ctx->r = r;
ctx->html_rewrite = false;
ctx->in_place = false;
ctx->follow_flushes = options->follow_flushes();
ctx->preserve_caching_headers = kDontPreserveHeaders;
// See build_context_for_request() in mod_instaweb.cc
@@ -1923,17 +1861,16 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
if (pagespeed_resource) {
// TODO(jefftk): Set using_spdy appropriately. See
// ProxyInterface::ProxyRequestCallback
ps_create_base_fetch(url.Spec(), ctx, request_context,
request_headers.release(), kPageSpeedResource,
options);
ps_create_base_fetch(ctx, request_context, request_headers.release(),
kPageSpeedResource);
ResourceFetch::Start(
url,
custom_options.release() /* null if there aren't custom options */,
cfg_s->server_context, ctx->base_fetch);
false /* using_spdy */, cfg_s->server_context, ctx->base_fetch);
return ps_async_wait_response(r);
} else if (is_an_admin_handler) {
ps_create_base_fetch(url.Spec(), ctx, request_context,
request_headers.release(), kAdminPage, options);
ps_create_base_fetch(ctx, request_context, request_headers.release(),
kAdminPage);
QueryParams query_params;
query_params.ParseFromUrl(url);
@@ -1981,8 +1918,8 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
if (options->domain_lawyer()->MapOriginUrl(
url, &mapped_url, &host_header, &is_proxy) && is_proxy) {
ps_create_base_fetch(url.Spec(), ctx, request_context,
request_headers.release(), kPageSpeedProxy, options);
ps_create_base_fetch(ctx, request_context, request_headers.release(),
kPageSpeedProxy);
RewriteDriver* driver;
if (custom_options.get() == NULL) {
@@ -2005,9 +1942,9 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
}
if (html_rewrite && options->IsAllowed(url.Spec())) {
ps_create_base_fetch(url.Spec(), ctx, request_context,
request_headers.release(), kHtmlTransform, options);
if (html_rewrite) {
ps_create_base_fetch(ctx, request_context, request_headers.release(),
kHtmlTransform);
// Do not store driver in request_context, it's not safe.
RewriteDriver* driver;
@@ -2035,7 +1972,8 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
url,
cfg_s->server_context,
options,
ctx->base_fetch);
ctx->base_fetch,
false /* requires_blink_cohort (no longer unused) */);
// Will call StartParse etc. The rewrite driver will take care of deleting
// itself if necessary.
@@ -2050,8 +1988,8 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
if (options->in_place_rewriting_enabled() &&
options->enabled() &&
options->IsAllowed(url.Spec())) {
ps_create_base_fetch(url.Spec(), ctx, request_context, request_headers.release(),
kIproLookup, options);
ps_create_base_fetch(ctx, request_context, request_headers.release(),
kIproLookup);
// Do not store driver in request_context, it's not safe.
RewriteDriver* driver;
@@ -2100,6 +2038,7 @@ void ps_send_to_pagespeed(ngx_http_request_t* r,
int last_buf = 0;
for (cur = in; cur != NULL; cur = cur->next) {
last_buf = cur->buf->last_buf;
// Buffers are not really the last buffer until they've been through
// pagespeed.
cur->buf->last_buf = 0;
@@ -2124,19 +2063,6 @@ void ps_send_to_pagespeed(ngx_http_request_t* r,
}
}
}
if (cur->buf->flush && ctx->follow_flushes) {
// Calling ctx->proxy_fetch->Flush(cfg_s->handler) will be a no-op here,
// unless we have follow_flushes or flush_html enabled. Note that PSOL
// might aggregate multiple flushes into 1, and actually flush a little bit
// later due to html parser state and earlier scheduled operations.
// Also, unless we also set the flush flag on the nginx buffers we won't
// actually flush.
// Note that too many flushes could harm optimization over larger html
// fragments as PSOL gets less context to work with, e.g. it can't combine
// two css files if a flush happens in between.
ctx->proxy_fetch->Flush(cfg_s->handler);
}
// We're done with buffers as we pass them through, so mark them as sent as
// we go.
cur->buf->pos = cur->buf->last;
@@ -2145,6 +2071,9 @@ void ps_send_to_pagespeed(ngx_http_request_t* r,
if (last_buf) {
ctx->proxy_fetch->Done(true /* success */);
ctx->proxy_fetch = NULL; // ProxyFetch deletes itself on Done().
} else {
// TODO(jefftk): Decide whether Flush() is warranted here.
ctx->proxy_fetch->Flush(cfg_s->handler);
}
}
@@ -2241,31 +2170,6 @@ ngx_int_t ps_etag_header_filter(ngx_http_request_t* r) {
r->gzip_vary = 0;
}
#endif
if (ctx && ctx->recorder) {
ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
int s_maxage_sec =
cfg_s->server_context->global_options()->EffectiveInPlaceSMaxAgeSec();
if (s_maxage_sec != -1) {
GoogleString existing_cache_control;
bool cache_control_present = ps_get_cache_control(
r, &existing_cache_control);
GoogleString updated_cache_control;
if (ResponseHeaders::ApplySMaxAge(s_maxage_sec,
existing_cache_control,
&updated_cache_control)) {
// We're modifing the cache control header; save a copy first.
// NULL indicates that the header was not present.
ctx->recorder->SaveCacheControl(
cache_control_present ? existing_cache_control.c_str() : NULL);
// Replace the cache-control with our new s-maxage-including one.
ps_set_cache_control(r, string_piece_to_pool_string(
r->pool, updated_cache_control));
}
}
}
return ngx_http_ef_next_header_filter(r);
}
@@ -2493,7 +2397,6 @@ ngx_int_t ps_in_place_check_header_filter(ngx_http_request_t* r) {
cache_url.c_str());
const SystemRewriteOptions* options = SystemRewriteOptions::DynamicCast(
ctx->driver->options());
RequestContextPtr request_context(
cfg_s->server_context->NewRequestContext(r));
request_context->set_options(options->ComputeHttpOptions());
@@ -2513,7 +2416,7 @@ ngx_int_t ps_in_place_check_header_filter(ngx_http_request_t* r) {
server_context->http_cache(),
server_context->statistics(),
message_handler);
// set in memory flag for in_place_body_filter
// set in memory flag for in place_body_filter
r->filter_need_in_memory = 1;
// We don't have the response headers at all yet because we haven't yet gone
@@ -2597,7 +2500,7 @@ ngx_int_t send_out_headers_and_body(
// Send the body.
ngx_chain_t* out;
rc = string_piece_to_buffer_chain(
r->pool, output, &out, true /* send_last_buf */, false);
r->pool, output, &out, true /* send_last_buf */);
if (rc == NGX_ERROR) {
return NGX_ERROR;
}
@@ -3028,7 +2931,7 @@ ngx_int_t ps_preaccess_handler(ngx_http_request_t* r) {
ngx_int_t ps_etag_filter_init(ngx_conf_t* cf) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
if (cfg_m->driver_factory != NULL) {
ngx_http_ef_next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ps_etag_header_filter;
}
@@ -3110,11 +3013,6 @@ ngx_int_t ps_init_module(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
// See https://github.com/pagespeed/ngx_pagespeed/issues/1220
if (cfg_m == NULL) {
return NGX_OK;
}
ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module));
ngx_http_core_srv_conf_t** cscfp = static_cast<ngx_http_core_srv_conf_t**>(
@@ -3182,7 +3080,7 @@ void ps_exit_child_process(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
NgxBaseFetch::Terminate();
if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
if (cfg_m->driver_factory != NULL) {
cfg_m->driver_factory->ShutDown();
}
}
@@ -3192,7 +3090,7 @@ void ps_exit_child_process(ngx_cycle_t* cycle) {
ngx_int_t ps_init_child_process(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
if (cfg_m == NULL || cfg_m->driver_factory == NULL) {
if (cfg_m->driver_factory == NULL) {
return NGX_OK;
}
+1 -2
View File
@@ -52,7 +52,7 @@ class InPlaceResourceRecorder;
// NGX_DECLINED immediately unless send_last_buf.
ngx_int_t string_piece_to_buffer_chain(
ngx_pool_t* pool, StringPiece sp,
ngx_chain_t** link_ptr, bool send_last_buf, bool send_flush);
ngx_chain_t** link_ptr, bool send_last_buf);
StringPiece str_to_string_piece(ngx_str_t s);
@@ -109,7 +109,6 @@ typedef struct {
// Location: headers that start with '/' without regarding X-Forwarded-Proto.
bool location_field_set;
bool psol_vary_accept_only;
bool follow_flushes;
} ps_request_ctx_t;
ps_request_ctx_t* ps_get_request_context(ngx_http_request_t* r);
+2 -37
View File
@@ -69,6 +69,7 @@ NgxRewriteDriverFactory::NgxRewriteDriverFactory(
SystemThreadSystem* system_thread_system, StringPiece hostname, int port)
: SystemRewriteDriverFactory(process_context, system_thread_system,
NULL /* default shared memory runtime */, hostname, port),
main_conf_(NULL),
threads_started_(false),
ngx_message_handler_(
new NgxMessageHandler(timer(), thread_system()->NewMutex())),
@@ -82,7 +83,7 @@ NgxRewriteDriverFactory::NgxRewriteDriverFactory(
ngx_shared_circular_buffer_(NULL),
hostname_(hostname.as_string()),
port_(port),
process_script_variables_mode_(ProcessScriptVariablesMode::kOff),
process_script_variables_(false),
process_script_variables_set_(false),
shut_down_(false) {
InitializeDefaultOptions();
@@ -147,19 +148,10 @@ NamedLockManager* NgxRewriteDriverFactory::DefaultLockManager() {
RewriteOptions* NgxRewriteDriverFactory::NewRewriteOptions() {
NgxRewriteOptions* options = new NgxRewriteOptions(thread_system());
// TODO(jefftk): figure out why using SetDefaultRewriteLevel like
// mod_pagespeed does in mod_instaweb.cc:create_dir_config() isn't enough here
// -- if you use that instead then ngx_pagespeed doesn't actually end up
// defaulting CoreFilters.
// See: https://github.com/pagespeed/ngx_pagespeed/issues/1190
options->SetRewriteLevel(RewriteOptions::kCoreFilters);
return options;
}
RewriteOptions* NgxRewriteDriverFactory::NewRewriteOptionsForQuery() {
return new NgxRewriteOptions(thread_system());
}
bool NgxRewriteDriverFactory::CheckResolver() {
if (use_native_fetcher_ && resolver_ == NULL) {
return false;
@@ -216,14 +208,6 @@ void NgxRewriteDriverFactory::StartThreads() {
threads_started_ = true;
}
void NgxRewriteDriverFactory::SetMainConf(NgxRewriteOptions* main_options) {
// Propagate process-scope options from the copy we had during nginx option
// parsing to our own.
if (main_options != NULL) {
default_options()->MergeOnlyProcessScopeOptions(*main_options);
}
}
void NgxRewriteDriverFactory::LoggingInit(
ngx_log_t* log, bool may_install_crash_handler) {
log_ = log;
@@ -266,23 +250,4 @@ void NgxRewriteDriverFactory::InitStats(Statistics* statistics) {
InPlaceResourceRecorder::InitStats(statistics);
}
void NgxRewriteDriverFactory::PrepareForkedProcess(const char* name) {
ngx_pid = ngx_getpid(); // Needed for logging to have the right PIDs.
SystemRewriteDriverFactory::PrepareForkedProcess(name);
}
void NgxRewriteDriverFactory::NameProcess(const char* name) {
SystemRewriteDriverFactory::NameProcess(name);
// Superclass set status with prctl. Nginx has a helper function for setting
// argv[0] as well, so let's use that. We'll show up as:
//
// nginx: pagespeed $name
char name_for_setproctitle[32];
snprintf(name_for_setproctitle, sizeof(name_for_setproctitle),
"pagespeed %s", name);
ngx_setproctitle(name_for_setproctitle);
}
} // namespace net_instaweb
+11 -18
View File
@@ -48,12 +48,6 @@ class SlowWorker;
class Statistics;
class SystemThreadSystem;
enum ProcessScriptVariablesMode {
kOff,
kLegacyRestricted,
kAll
};
class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
public:
// We take ownership of the thread system.
@@ -69,9 +63,8 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
virtual Timer* DefaultTimer();
virtual NamedLockManager* DefaultLockManager();
// Create a new RewriteOptions. In this implementation it will be an
// NgxRewriteOptions, and it will have CoreFilters explicitly set.
// NgxRewriteOptions.
virtual RewriteOptions* NewRewriteOptions();
virtual RewriteOptions* NewRewriteOptionsForQuery();
virtual ServerContext* NewDecodingServerContext();
// Check resolver configured or not.
bool CheckResolver();
@@ -97,7 +90,7 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
InitStats(statistics);
}
void SetMainConf(NgxRewriteOptions* main_conf);
void set_main_conf(NgxRewriteOptions* main_conf) { main_conf_ = main_conf; }
void set_resolver(ngx_resolver_t* resolver) {
resolver_ = resolver;
@@ -118,8 +111,8 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
void set_native_fetcher_max_keepalive_requests(int x) {
native_fetcher_max_keepalive_requests_ = x;
}
ProcessScriptVariablesMode process_script_variables() {
return process_script_variables_mode_;
bool process_script_variables() {
return process_script_variables_;
}
void LoggingInit(ngx_log_t* log, bool may_install_crash_handler);
@@ -128,22 +121,22 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
virtual void SetCircularBuffer(SharedCircularBuffer* buffer);
bool SetProcessScriptVariables(ProcessScriptVariablesMode mode) {
bool SetProcessScriptVariables(bool process_script_variables) {
if (!process_script_variables_set_) {
process_script_variables_mode_ = mode;
process_script_variables_ = process_script_variables;
process_script_variables_set_ = true;
return true;
}
return false;
}
virtual void PrepareForkedProcess(const char* name);
virtual void NameProcess(const char* name);
private:
Timer* timer_;
// main_conf will have only options set in the main block. It may be NULL,
// and we do not take ownership.
NgxRewriteOptions* main_conf_;
bool threads_started_;
NgxMessageHandler* ngx_message_handler_;
NgxMessageHandler* ngx_html_parse_message_handler_;
@@ -164,7 +157,7 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
GoogleString hostname_;
int port_;
ProcessScriptVariablesMode process_script_variables_mode_;
bool process_script_variables_;
bool process_script_variables_set_;
bool shut_down_;
+35 -59
View File
@@ -112,7 +112,7 @@ void NgxRewriteOptions::AddProperties() {
false);
add_ngx_option(
"", &NgxRewriteOptions::global_statistics_path_, "ngsp",
kGlobalStatisticsPath, kProcessScopeStrict,
kGlobalStatisticsPath, kProcessScope,
"Set the global statistics path. Ex: /ngx_pagespeed_global_statistics",
false);
add_ngx_option(
@@ -127,8 +127,7 @@ void NgxRewriteOptions::AddProperties() {
kServerScope, "Set the admin path. Ex: /pagespeed_admin", false);
add_ngx_option(
"", &NgxRewriteOptions::global_admin_path_, "ngap", kGlobalAdminPath,
kProcessScopeStrict,
"Set the global admin path. Ex: /pagespeed_global_admin",
kProcessScope, "Set the global admin path. Ex: /pagespeed_global_admin",
false);
MergeSubclassProperties(ngx_properties_);
@@ -181,10 +180,10 @@ RewriteOptions::OptionScope NgxRewriteOptions::GetOptionScope(
it != all_options().end(); ++it) {
RewriteOptions::OptionBase* option = *it;
if (option->option_name() == option_name) {
// We treat kLegacyProcessScope as kProcessScopeStrict, failing to start
// if an option is out of place.
return option->scope() == kLegacyProcessScope ? kProcessScopeStrict
: option->scope();
// We treat kProcessScope as kProcessScopeStrict, failing to start if an
// option is out of place.
return option->scope() == kProcessScope ? kProcessScopeStrict
: option->scope();
}
}
return kDirectoryScope;
@@ -259,8 +258,7 @@ const char* ps_error_string_for_option(
const char* NgxRewriteOptions::ParseAndSetOptions(
StringPiece* args, int n_args, ngx_pool_t* pool, MessageHandler* handler,
NgxRewriteDriverFactory* driver_factory,
RewriteOptions::OptionScope scope, ngx_conf_t* cf,
ProcessScriptVariablesMode script_mode) {
RewriteOptions::OptionScope scope, ngx_conf_t* cf, bool compile_scripts) {
CHECK_GE(n_args, 1);
StringPiece directive = args[0];
@@ -276,43 +274,20 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
pool, directive, "cannot be set at this scope.");
}
bool compile_scripts = false;
if (script_mode != ProcessScriptVariablesMode::kOff) {
// In the old mode we only allowed a few, so restrict to those.
compile_scripts =
StringCaseStartsWith(directive, "LoadFromFile") ||
StringCaseEqual(directive, "EnableFilters") ||
StringCaseEqual(directive, "DisableFilters") ||
StringCaseEqual(directive, "DownstreamCachePurgeLocationPrefix") ||
StringCaseEqual(directive, "DownstreamCachePurgeMethod") ||
StringCaseEqual(directive,
"DownstreamCacheRewrittenPercentageThreshold") ||
StringCaseEqual(directive, "ShardDomain");
// In the new behaviour we also allow scripting of query- and directory-
// scoped options.
compile_scripts |=
script_mode == ProcessScriptVariablesMode::kAll &&
(GetOptionScope(directive) <= RewriteOptions::kDirectoryScope ||
(StringCaseEqual(directive, "Allow") ||
StringCaseEqual(directive, "BlockingRewriteRefererUrls") ||
StringCaseEqual(directive, "Disallow") ||
StringCaseEqual(directive, "DistributableFilters") ||
StringCaseEqual(directive, "Domain") ||
StringCaseEqual(directive, "ExperimentVariable") ||
StringCaseEqual(directive, "ExperimentSpec") ||
StringCaseEqual(directive, "ForbidFilters") ||
StringCaseEqual(directive, "RetainComment") ||
StringCaseEqual(directive, "CustomFetchHeader") ||
StringCaseEqual(directive, "MapOriginDomain") ||
StringCaseEqual(directive, "MapProxyDomain") ||
StringCaseEqual(directive, "MapRewriteDomain") ||
StringCaseEqual(directive, "UrlValuedAttribute") ||
StringCaseEqual(directive, "Library")));
}
ScriptLine* script_line;
script_line = NULL;
// Note that LoadFromFile should not be scriptable on wildcard hosts,
// as browsers might be able to manipulate its natural use-case: $http_host.
if (!StringCaseStartsWith(directive, "LoadFromFile") &&
!StringCaseEqual(directive, "EnableFilters") &&
!StringCaseEqual(directive, "DisableFilters") &&
!StringCaseEqual(directive, "DownstreamCachePurgeLocationPrefix") &&
!StringCaseEqual(directive, "DownstreamCachePurgeMethod") &&
!StringCaseEqual(directive,
"DownstreamCacheRewrittenPercentageThreshold") &&
!StringCaseEqual(directive, "ShardDomain")){
compile_scripts = false;
}
if (n_args == 1 && StringCaseEqual(directive, "ClearInheritedScripts")) {
clear_inherited_scripts_ = true;
@@ -388,23 +363,24 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
}
} else if (StringCaseEqual("ProcessScriptVariables", args[0])) {
if (scope == RewriteOptions::kProcessScopeStrict) {
ProcessScriptVariablesMode mode;
if (StringCaseEqual(arg, "all")) {
mode = ProcessScriptVariablesMode::kAll;
} else if (StringCaseEqual(arg, "on")) {
mode = ProcessScriptVariablesMode::kLegacyRestricted;
if (StringCaseEqual(arg, "on")) {
if (driver_factory->SetProcessScriptVariables(true)) {
result = RewriteOptions::kOptionOk;
} else {
return const_cast<char*>(
"pagespeed ProcessScriptVariables: can only be set once");
}
} else if (StringCaseEqual(arg, "off")) {
mode = ProcessScriptVariablesMode::kOff;
if (driver_factory->SetProcessScriptVariables(false)) {
result = RewriteOptions::kOptionOk;
} else {
return const_cast<char*>(
"pagespeed ProcessScriptVariables: can only be set once");
}
} else {
return const_cast<char*>(
"pagespeed ProcessScriptVariables: invalid value");
}
if (driver_factory->SetProcessScriptVariables(mode)) {
result = RewriteOptions::kOptionOk;
} else {
return const_cast<char*>(
"pagespeed ProcessScriptVariables: can only be set once");
}
} else {
return const_cast<char*>(
"ProcessScriptVariables is only allowed at the top level");
@@ -415,7 +391,7 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
result = driver_factory->ParseAndSetOption1(
directive,
arg,
scope >= RewriteOptions::kLegacyProcessScope,
scope >= RewriteOptions::kProcessScope,
&msg,
handler);
}
@@ -428,7 +404,7 @@ const char* NgxRewriteOptions::ParseAndSetOptions(
directive,
args[1],
args[2],
scope >= RewriteOptions::kLegacyProcessScope,
scope >= RewriteOptions::kProcessScope,
&msg,
handler);
}
@@ -500,7 +476,7 @@ bool NgxRewriteOptions::ExecuteScriptVariables(
const char* status = ParseAndSetOptions(args, script_line->n_args(),
r->pool, handler, driver_factory, script_line->scope(), NULL /*cf*/,
ProcessScriptVariablesMode::kOff);
false /*compile scripts*/);
if (status != NULL) {
script_error = true;
+1 -3
View File
@@ -29,8 +29,6 @@ extern "C" {
#include <vector>
#include "ngx_rewrite_driver_factory.h"
#include "net/instaweb/rewriter/public/rewrite_options.h"
#include "pagespeed/kernel/base/message_handler.h"
#include "pagespeed/kernel/base/ref_counted_ptr.h"
@@ -133,7 +131,7 @@ class NgxRewriteOptions : public SystemRewriteOptions {
const char* ParseAndSetOptions(
StringPiece* args, int n_args, ngx_pool_t* pool, MessageHandler* handler,
NgxRewriteDriverFactory* driver_factory, OptionScope scope,
ngx_conf_t* cf, ProcessScriptVariablesMode script_mode);
ngx_conf_t* cf, bool compile_scripts);
bool ExecuteScriptVariables(
ngx_http_request_t* r, MessageHandler* handler,
NgxRewriteDriverFactory* driver_factory);
+6 -19
View File
@@ -35,8 +35,7 @@ namespace net_instaweb {
NgxServerContext::NgxServerContext(
NgxRewriteDriverFactory* factory, StringPiece hostname, int port)
: SystemServerContext(factory, hostname, port),
ngx_http2_variable_index_(NGX_ERROR) {
: SystemServerContext(factory, hostname, port) {
}
NgxServerContext::~NgxServerContext() { }
@@ -71,23 +70,11 @@ SystemRequestContext* NgxServerContext::NewRequestContext(
local_ip.len = 0;
}
SystemRequestContext* ctx = new SystemRequestContext(
thread_system()->NewMutex(), timer(),
ps_determine_host(r), local_port, str_to_string_piece(local_ip));
// See if http2 is in use.
if (ngx_http2_variable_index_ >= 0) {
ngx_http_variable_value_t* val =
ngx_http_get_indexed_variable(r, ngx_http2_variable_index_);
if (val != NULL && val->valid) {
StringPiece str_val(reinterpret_cast<char*>(val->data), val->len);
if (str_val == "h2" || str_val == "h2c") {
ctx->set_using_http2(true);
}
}
}
return ctx;
return new SystemRequestContext(thread_system()->NewMutex(),
timer(),
ps_determine_host(r),
local_port,
str_to_string_piece(local_ip));
}
GoogleString NgxServerContext::FormatOption(StringPiece option_name,
-10
View File
@@ -58,18 +58,8 @@ class NgxServerContext : public SystemServerContext {
virtual GoogleString FormatOption(StringPiece option_name, StringPiece args);
void set_ngx_http2_variable_index(ngx_int_t idx) {
ngx_http2_variable_index_ = idx;
}
ngx_int_t ngx_http2_variable_index() const {
return ngx_http2_variable_index_;
}
private:
NgxRewriteDriverFactory* ngx_factory_;
// what index the "http2" var is, or NGX_ERROR.
ngx_int_t ngx_http2_variable_index_;
DISALLOW_COPY_AND_ASSIGN(NgxServerContext);
};
+31 -141
View File
@@ -31,7 +31,6 @@
: ${NATIVE_FETCHER:?"Set NATIVE_FETCHER to off or on"}
: ${PRIMARY_PORT:?"Set PRIMARY_PORT"}
: ${SECONDARY_PORT:?"Set SECONDARY_PORT"}
: ${CONTROLLER_PORT:?"Set CONTROLLER_PORT"}
: ${RCPORT1:?"Set RCPORT1"}
: ${RCPORT2:?"Set RCPORT2"}
: ${RCPORT2:?"Set RCPORT3"}
@@ -43,28 +42,11 @@
: ${NGINX_EXECUTABLE:?"Set NGINX_EXECUTABLE"}
: ${PAGESPEED_TEST_HOST:?"Set PAGESPEED_TEST_HOST"}
POSITION_AUX="${POSITION_AUX:-unset}"
RUN_CONTROLLER_TEST="${RUN_CONTROLLER_TEST:-off}"
PRIMARY_HOSTNAME="localhost:$PRIMARY_PORT"
SECONDARY_HOSTNAME="localhost:$SECONDARY_PORT"
this_dir="$( cd $(dirname "$0") && pwd)"
echo this_dir=$this_dir
TEST_TMP="$this_dir/tmp"
rm -rf "$TEST_TMP"
mkdir -p "$TEST_TMP"
echo TEST_TMP=$TEST_TMP
APACHE_DOC_SRC="$MOD_PAGESPEED_DIR/src/install/"
SERVER_ROOT="$TEST_TMP/root"
echo SERVER_ROOT=$SERVER_ROOT
rm -rf "$SERVER_ROOT"
mkdir -p "$SERVER_ROOT"
export APACHE_DOC_ROOT="$SERVER_ROOT"
mkdir -p "$APACHE_DOC_ROOT"
make -f "$APACHE_DOC_SRC/Makefile.tests" setup_doc_root \
INSTALL_DATA_DIR="$APACHE_DOC_SRC"
SERVER_ROOT="$MOD_PAGESPEED_DIR/src/install/"
# We need check and check_not before we source SYSTEM_TEST_FILE that provides
# them.
@@ -154,19 +136,17 @@ function fire_ab_load() {
sleep 2
}
this_dir="$( cd $(dirname "$0") && pwd)"
# stop nginx/valgrind
killall -s KILL nginx
# TODO(oschaaf): Fix waiting for valgrind on 32 bits systems.
killall -s KILL memcheck-amd64-
killall -s KILL memcheck-x86-
SECONDS=0
while pgrep -x nginx >/dev/null || pgrep memcheck >/dev/null;do
if [ $SECONDS -gt 20 ]; then
echo "Old processes won't die" >&2
exit 1
fi
sleep 1
done
while pgrep nginx > /dev/null; do sleep 1; done
while pgrep memcheck > /dev/null; do sleep 1; done
TEST_TMP="$this_dir/tmp"
rm -r "$TEST_TMP"
check_simple mkdir -p "$TEST_TMP"
PROXY_CACHE="$TEST_TMP/proxycache"
TMP_PROXY_CACHE="$TEST_TMP/tmpproxycache"
@@ -196,12 +176,6 @@ else
RESOLVER=""
fi
if [ "$RUN_CONTROLLER_TEST" = "on" ]; then
CONTROLLER="pagespeed CentralControllerPort $CONTROLLER_PORT;"
else
CONTROLLER=""
fi
# set up the config file for the test
PAGESPEED_CONF="$TEST_TMP/pagespeed_test.conf"
PAGESPEED_CONF_TEMPLATE="$this_dir/pagespeed_test.conf.template"
@@ -226,7 +200,6 @@ cat $PAGESPEED_CONF_TEMPLATE \
| sed 's#@@SERVER_ROOT@@#'"$SERVER_ROOT"'#' \
| sed 's#@@PRIMARY_PORT@@#'"$PRIMARY_PORT"'#' \
| sed 's#@@SECONDARY_PORT@@#'"$SECONDARY_PORT"'#' \
| sed 's#@@CONTROLLER@@#'"$CONTROLLER"'#' \
| sed 's#@@NATIVE_FETCHER@@#'"$NATIVE_FETCHER"'#' \
| sed 's#@@RESOLVER@@#'"$RESOLVER"'#' \
| sed 's#@@RCPORT1@@#'"$RCPORT1"'#' \
@@ -247,7 +220,7 @@ if $USE_VALGRIND; then
--show-possibly-lost=no --log-file=$TEST_TMP/valgrind.log \
--suppressions="$this_dir/valgrind.sup" \
$NGINX_EXECUTABLE -c $PAGESPEED_CONF) & VALGRIND_PID=$!
trap "echo 'terminating valgrind!' && kill -s TERM $VALGRIND_PID" EXIT
trap "echo 'terminating valgrind!' && kill -s sigterm $VALGRIND_PID" EXIT
echo "Wait until nginx is ready to accept connections"
while ! curl -I "http://$PRIMARY_HOSTNAME/mod_pagespeed_example/" 2>/dev/null; do
sleep 0.1;
@@ -302,7 +275,7 @@ else
if $USE_VALGRIND; then
# Clear valgrind trap
trap - EXIT
echo "To end valgrind, run 'kill -s TERM $VALGRIND_PID'"
echo "To end valgrind, run 'kill -s quit $VALGRIND_PID'"
fi
echo "Not running tests; commence manual testing"
exit 4
@@ -316,16 +289,8 @@ CACHE_PURGE_METHODS="PURGE GET"
SERVER_NAME=nginx
# TODO(cheesy): add an nginx controller test variant. Actually requires some
# thought as we don't currently have a multi-phase test flow in ngx_pagespeeed,
# as far as I can tell, and we really have to update the config and restart
# since the controller is a global setting.
RUN_CONTROLLER_TEST=${RUN_CONTROLLER_TEST:-off}
# run generic system tests
PAGESPEED_DIR="$MOD_PAGESPEED_DIR/src/pagespeed"
SYSTEM_TEST_FILE="$PAGESPEED_DIR/system/system_test.sh"
REMOTE_CONFIG_TEST_FILE="$PAGESPEED_DIR/system/remote_config_test.sh"
SYSTEM_TEST_FILE="$MOD_PAGESPEED_DIR/src/pagespeed/system/system_test.sh"
if [ ! -e "$SYSTEM_TEST_FILE" ] ; then
echo "Not finding $SYSTEM_TEST_FILE -- is mod_pagespeed not in a parallel"
@@ -338,8 +303,7 @@ BEACON_HANDLER="ngx_pagespeed_beacon"
STATISTICS_HANDLER="ngx_pagespeed_statistics"
GLOBAL_STATISTICS_HANDLER="ngx_pagespeed_global_statistics"
MESSAGES_HANDLER="ngx_pagespeed_message"
STATISTICS_URL=http://$PRIMARY_HOSTNAME/$STATISTICS_HANDLER
GLOBAL_STATISTICS_URL=http://$PRIMARY_HOSTNAME/$GLOBAL_STATISTICS_HANDLER
STATISTICS_URL=http://$PRIMARY_HOSTNAME/ngx_pagespeed_statistics
# An expected failure can be indicated like: "~In-place resource optimization~"
PAGESPEED_EXPECTED_FAILURES="
@@ -368,6 +332,7 @@ if $USE_VALGRIND; then
~combine_css Maximum size of combined CSS.~
~prioritize_critical_css~
~prioritize_critical_css Able to read POST data from temp file.~
~IPRO flow uses cache as expected.~
~IPRO flow doesn't copy uncacheable resources multiple times.~
~inline_unauthorized_resources allows unauthorized css selectors~
"
@@ -377,7 +342,6 @@ fi
# wants different ones than we want, so we need to reset our positional args.
set -- "$PRIMARY_HOSTNAME"
source $SYSTEM_TEST_FILE
source $REMOTE_CONFIG_TEST_FILE
# nginx-specific system tests
@@ -614,93 +578,30 @@ check test $(scrape_stat image_rewrite_total_original_bytes) -ge 10000
# happens both before and after.
start_test "Reload config"
function find_exactly_once {
test $(grep -c "$1") -eq 1
}
if [ "$RUN_CONTROLLER_TEST" = "on" ]; then
function check_process_names() {
if ! $USE_VALGRIND; then
# There should be one babysitter and controller running. Under valgrind
# process labels are confused, so skip the check then.
running=$(ps auxww | grep 'ngin[x]')
check_from "$running" find_exactly_once "nginx: pagespeed babysitter"
check_from "$running" find_exactly_once "nginx: pagespeed controller"
fi
}
check_process_names
fi
# Fire up some heavy load if ab is available to test a stressed reload.
# TODO(oschaaf): make sure we wait for the new worker to get ready to accept
# requests.
fire_ab_load
URL="$EXAMPLE_ROOT/styles/W.rewrite_css_images.css.pagespeed.cf.Hash.css"
check wget "$URL" -O /dev/null
check wget $EXAMPLE_ROOT/styles/W.rewrite_css_images.css.pagespeed.cf.Hash.css \
-O /dev/null
check_simple "$NGINX_EXECUTABLE" -s reload -c "$PAGESPEED_CONF"
# Wait for the new worker process with the new configuration to get ready, or
# else the sudden reset of the shared mem statistics/cache might catch upcoming
# tests unaware.
function wait_for_new_worker() {
while [ $(scrape_stat image_rewrite_total_original_bytes) -gt 0 ]; do
while [ $(scrape_stat image_rewrite_total_original_bytes) -gt 0 ]
do
echo "Waiting for new worker to get ready..."
sleep .1
done
}
wait_for_new_worker
check wget "$URL" -O /dev/null
done
check wget $EXAMPLE_ROOT/styles/W.rewrite_css_images.css.pagespeed.cf.Hash.css \
-O /dev/null
if [ "$AB_PID" != "0" ]; then
echo "Kill ab (pid: $AB_PID)"
kill -s KILL $AB_PID &>/dev/null || true
fi
# There should still be just one babysitter and controller running.
if [ "$RUN_CONTROLLER_TEST" = "on" ]; then
check_process_names
check grep "Writing a byte to a pipe to tell the old controller to exit." \
$ERROR_LOG
check grep "Root process is starting a new controller; shutting down." \
$ERROR_LOG
fi
start_test "Shared memory checkpointing"
# We do two tests here:
# 1. Metadata cache: check that an IPRO'd image is still fully optimized after a
# restart.
# 2. Property cache: prioritize critical CSS persists beacon results across
# restarts.
IPRO_URL="$EXAMPLE_ROOT/images/Cuppa.png"
# Checkpoint beacon results to disk if we haven't already.
check wget "$IPRO_URL" -O /dev/null
test_prioritize_critical_css
sleep 2
check wget "$IPRO_URL" -O /dev/null
test_prioritize_critical_css
# Reload nginx again.
check_simple "$NGINX_EXECUTABLE" -s reload -c "$PAGESPEED_CONF"
wait_for_new_worker
# The image should be fully optimized.
OUT=$($CURL -sS -D- -o/dev/null "$IPRO_URL")
check_from "$OUT" grep ^X-Original-Content-Length:
check_from "$OUT" grep ^Content-Length:
content_length=$(echo "$OUT" | grep ^Content-Length: | grep -o [0-9]*)
original_content_length=$(echo "$OUT" | grep ^X-Original-Content-Length: \
| grep -o [0-9]*)
check [ "$original_content_length" -gt "$content_length" ]
# The beacon responses are stored in the metadata cache, so this can only pass
# if we persisted the metadata across restarts.
test_prioritize_critical_css_final
# This is dependent upon having a beacon handler.
test_filter add_instrumentation beacons load.
@@ -745,14 +646,14 @@ check touch "$SECONDARY_CACHE/cache.flush"
check touch "$IPRO_CACHE/cache.flush"
sleep 1
CACHE_TESTING_DIR="$SERVER_ROOT/cache_flush/"
CACHE_TESTING_DIR="$SERVER_ROOT/mod_pagespeed_test/cache_flush/"
CACHE_TESTING_TMPDIR="$CACHE_TESTING_DIR/$$"
mkdir "$CACHE_TESTING_TMPDIR"
cp "$CACHE_TESTING_DIR/cache_flush_test.html" "$CACHE_TESTING_TMPDIR/"
CSS_FILE="$CACHE_TESTING_TMPDIR/update.css"
echo ".class myclass { color: $COLOR0; }" > "$CSS_FILE"
URL_PATH="cache_flush/$$/cache_flush_test.html"
URL_PATH="mod_pagespeed_test/cache_flush/$$/cache_flush_test.html"
URL="$SECONDARY_HOSTNAME/$URL_PATH"
CACHE_A="--header=Host:cache_a.example.com"
@@ -1348,6 +1249,10 @@ OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1) || tr
# We ignored the exit code, check if we got a 404 response.
check_from "$OUT" fgrep -qi '404'
if false; then
# This test fails on 1.11, but passes on trunk. While 2b4c097 fixed most users,
# it's still possible to get two Vary: Accept-Encoding headers in this test, so
# disable it for now.
start_test Single Vary: Accept-Encoding header in IPRO flow
URL=http://psol-vary.example.com/mod_pagespeed_example/styles/index_style.css
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
@@ -1364,15 +1269,7 @@ OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -O /dev/null -S $URL 2>&1)
MATCHES=$(echo "$OUT" | grep -c "Vary: Accept-Encoding") || true
check [ $MATCHES -eq 1 ]
start_test Follow flushes can be turned off.
echo "Check that FollowFlushes off outputs a single chunk"
check_flushing noflush 5.4 1
start_test Special responses from php are handled OK.
URL="http://special-response.example.com/A.foo.css.pagespeed.cf.0.css"
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -S --content-on-error $URL 2>&1) || true
check_from "$OUT" fgrep -qi '404'
check_from "$OUT" fgrep -q "PHP with a call to flush"
fi
start_test Shutting down.
@@ -1380,8 +1277,7 @@ start_test Shutting down.
fire_ab_load
if $USE_VALGRIND; then
# SIGQUIT requests a graceful shutdown.
kill -s QUIT $VALGRIND_PID
kill -s quit $VALGRIND_PID
while pgrep memcheck > /dev/null; do sleep 1; done
# Clear the previously set trap, we don't need it anymore.
trap - EXIT
@@ -1390,12 +1286,12 @@ if $USE_VALGRIND; then
check_not [ -s "$TEST_TMP/valgrind.log" ]
else
check_simple "$NGINX_EXECUTABLE" -s quit -c "$PAGESPEED_CONF"
while pgrep -x nginx > /dev/null; do sleep 1; done
while pgrep nginx > /dev/null; do sleep 1; done
fi
if [ "$AB_PID" != "0" ]; then
echo "Kill ab (pid: $AB_PID)"
kill -s KILL $AB_PID &>/dev/null || true
killall -s KILL $AB_PID &>/dev/null || true
fi
start_test Logged output looks healthy.
@@ -1422,8 +1318,6 @@ OUT=$(cat "$ERROR_LOG" \
| grep -v "\\[warn\\].*Resource based on.*ngx_pagespeed_statistics.*" \
| grep -v "\\[warn\\].*Canceling 1 functions on sequence Shutdown.*" \
| grep -v "\\[warn\\].*using uninitialized.*" \
| grep -v "\\[warn\\].*Controller process .* exited with wait status 9" \
| grep -v "\\[warn\\].*Controller process .* exited with wait status 15" \
| grep -v "\\[error\\].*BadName*" \
| grep -v "\\[error\\].*/mod_pagespeed/bad*" \
| grep -v "\\[error\\].*doesnotexist.css.*" \
@@ -1452,12 +1346,8 @@ OUT=$(cat "$ERROR_LOG" \
| grep -v "\\[warn\\].*remote\.cfg.*" \
| grep -v "\\[warn\\].*end token not received.*" \
| grep -v "\\[warn\\].*failed to hook next event.*" \
| grep -v "\\[warn\\].*Fetch timed out:.*" \
| grep -v "\\[warn\\].*Controller process .* exited with status code.*" \
| grep -v "\\[warn\\].*Rewrite.*failed.*.pagespeed....0.foo.*" \
| grep -v "\\[warn\\].*A.blue.css.*but cannot access the original.*" \
| grep -v "\\[warn\\].*Adding function to sequence.*" \
| grep -v "\\[warn\\].*special-response.*foo.css.*but cannot access the original.*" \
|| true)
check [ -z "$OUT" ]
+16 -234
View File
@@ -30,7 +30,7 @@ http {
proxy_cache_path "@@PROXY_CACHE@@" levels=1:2 keys_zone=htmlcache:60m inactive=90m max_size=50m;
proxy_temp_path "@@TMP_PROXY_CACHE@@";
pagespeed ProcessScriptVariables all;
pagespeed ProcessScriptVariables on;
pagespeed StatisticsPath /ngx_pagespeed_statistics;
pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
pagespeed ConsolePath /pagespeed_console;
@@ -63,12 +63,6 @@ http {
pagespeed CreateSharedMemoryMetadataCache "@@SHM_CACHE@@" 8192;
pagespeed BlockingRewriteKey psatest;
# We need to checkpoint more frequently than usual so that our checkpointing
# test will definitly have seen one of these intervals and so not be flaky.
# This needs to have a 1s interval because the checkpointing test has a 2s
# sleep.
pagespeed ShmMetadataCacheCheckpointIntervalSec 1;
# CriticalImagesBeaconEnabled is now on by default, but we disable in testing.
# With this option enabled, the inline image system test will currently fail.
# When critical image beaconing is enabled, only critical images are inlined.
@@ -85,9 +79,6 @@ http {
pagespeed StatisticsLogging on;
pagespeed LogDir "@@TEST_TMP@@/logdir";
# Expanded to CentralControllerPort directive when RUN_CONTROLLER_TEST=on
@@CONTROLLER@@
server {
# Sets up a logical home-page server on
# max-cacheable-content-length.example.com. This server is only used to
@@ -104,34 +95,6 @@ http {
pagespeed MaxCacheableContentLength 85;
}
# Test how load from file handles maximum sizes.
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name lff-large-files.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed MaxCacheableContentLength 4096;
pagespeed LoadFromFile
"http://lff-large-files.example.com/"
"@@SERVER_ROOT@@/";
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name lff-large-files-no-fallback.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed MaxCacheableContentLength 4096;
# http://lff-large-files-no-fallback.example.com/foo.css won't load, because
# we've configured a LoadFromFile pattern that doesn't match the path the
# webserver would take.
pagespeed LoadFromFile
"http://lff-large-files-no-fallback.example.com/"
"@@SERVER_ROOT@@/mod_pagespeed_example/styles/";
}
pagespeed UseNativeFetcher "@@NATIVE_FETCHER@@";
@@RESOLVER@@
@@ -174,7 +137,7 @@ http {
# inline_images (ii), defer_javascript (dj), webp (jw) and lossless_webp
# (ws).
if ($http_user_agent ~*
"Chrome/[2][3-9]+\.|Chrome/[3-9][0-9]+\.|Chrome/[0-9]{3,}\.") {
"Chrome/[2][3-9]+\.|Chrome/[[3-9][0-9]+\.|Chrome/[0-9]{3,}\.") {
set $ps_capability_list "ll,ii,dj,jw,ws:";
}
# Cache-fragment 3: This fragment contains (a) Desktop User-Agents that
@@ -601,10 +564,6 @@ http {
pagespeed UrlValuedAttribute img alt-src Image;
pagespeed UrlValuedAttribute video alt-a Image;
pagespeed UrlValuedAttribute video alt-b Image;
pagespeed UrlValuedAttribute link data-stylesheet Stylesheet;
pagespeed UrlValuedAttribute span data-stylesheet-a Stylesheet;
pagespeed UrlValuedAttribute span data-stylesheet-b Stylesheet;
pagespeed UrlValuedAttribute span data-stylesheet-c Stylesheet;
# Also test that we can redefine spec-defined attributes.
pagespeed UrlValuedAttribute blockquote cite Image;
@@ -849,7 +808,7 @@ http {
server_name www.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@;
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_css,rewrite_images;
@@ -863,7 +822,7 @@ http {
server_name origin.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@;
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_css,rewrite_images;
@@ -877,7 +836,7 @@ http {
server_name cdn.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@/;
pagespeed LoadFromFile http://cdn.example.com @@SERVER_ROOT@@;
pagespeed MapRewriteDomain cdn.example.com origin.example.com;
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters rewrite_css,rewrite_images;
@@ -1290,17 +1249,6 @@ http {
add_header 'X-Accel-Redirect' 'blablabla';
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name map-static-domain.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed MapRewriteDomain http://static-cdn.example.com
http://map-static-domain.example.com;
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters defer_javascript,rewrite_domains;
}
# Proxy + IPRO a gzip'd file for testing Issue 896.
server {
listen @@SECONDARY_PORT@@;
@@ -1318,44 +1266,6 @@ http {
}
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name compressedcache.example.com;
pagespeed on;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed EnableFilters rewrite_css;
pagespeed HttpCacheCompressionLevel 9;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffering off;
}
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name uncompressedcache.example.com;
pagespeed on;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed EnableFilters rewrite_css;
pagespeed HttpCacheCompressionLevel 0;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffering off;
}
}
server {
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
@@ -1418,7 +1328,7 @@ http {
listen [::]:@@SECONDARY_PORT@@;
server_name proxy-post-origin.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
root "@@SERVER_ROOT@@/";
root "@@SERVER_ROOT@@";
}
server {
@@ -1436,7 +1346,7 @@ http {
listen [::]:@@SECONDARY_PORT@@;
server_name script-filters.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
root "@@SERVER_ROOT@@/";
root "@@SERVER_ROOT@@";
set $filters "";
set $domain_shards "cdn1.example.com,cdn2.example.com";
if ($http_X_Script) {
@@ -1458,7 +1368,7 @@ http {
pagespeed EnableCachePurge on;
pagespeed PurgeMethod PURGE;
root "@@SERVER_ROOT@@/purge";
root "@@SERVER_ROOT@@/mod_pagespeed_test/purge";
pagespeed FileCachePath "@@FILE_CACHE@@_purge";
pagespeed DisableFilters add_instrumentation;
pagespeed RewriteLevel PassThrough;
@@ -1474,7 +1384,7 @@ http {
pagespeed EnableCachePurge on;
pagespeed PurgeMethod PURGE;
root "@@SERVER_ROOT@@/purge";
root "@@SERVER_ROOT@@/mod_pagespeed_test/purge";
pagespeed FileCachePath "@@FILE_CACHE@@_dir_on";
pagespeed DisableFilters add_instrumentation;
pagespeed RewriteLevel PassThrough;
@@ -1492,7 +1402,7 @@ http {
pagespeed InPlaceResourceOptimization off;
pagespeed off;
pagespeed FileCachePath "@@FILE_CACHE@@";
root "@@SERVER_ROOT@@/";
root "@@SERVER_ROOT@@";
location /mod_pagespeed_test/nostore {
add_header "Cache-Control" "max-age=12345";
add_header "Cache-Control" "public, no-store";
@@ -1507,7 +1417,7 @@ http {
pagespeed InPlaceResourceOptimization off;
pagespeed off;
pagespeed FileCachePath "@@FILE_CACHE@@";
root "@@SERVER_ROOT@@/";
root "@@SERVER_ROOT@@";
location / {
add_header "PageSpeedFilters" "add_instrumentation";
}
@@ -1520,7 +1430,7 @@ http {
pagespeed InPlaceResourceOptimization off;
pagespeed off;
pagespeed FileCachePath "@@FILE_CACHE@@";
root "@@SERVER_ROOT@@/";
root "@@SERVER_ROOT@@";
location / {
add_header "PageSpeed" "off";
}
@@ -1606,70 +1516,7 @@ http {
pagespeed InPlaceResourceOptimization on;
pagespeed FileCachePath "@@FILE_CACHE@@";
}
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name flush.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed RewriteDeadlinePerFlushMs 1;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffering off;
}
}
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name noflush.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed RewriteDeadlinePerFlushMs 1;
pagespeed FollowFlushes off;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffering off;
}
}
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name special-response.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
error_page 404 /mod_pagespeed_test/php_withflush.php;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
}
}
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name debug-filters.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters debug;
}
server {
listen @@PRIMARY_PORT@@;
listen [::]:@@PRIMARY_PORT@@;
@@ -1683,14 +1530,6 @@ http {
}
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
# TODO(oschaaf): The following breaks nginx starting up, as the bad header
# value gets rejected during configuration parsing. However, we can't easily
# build a test for that right now.
# pagespeed AddResourceHeader "X-Fo\n\no" "Bar";
# pagespeed AddResourceHeader "X-Foo" "Ba\nr";
# For testing that AddResourceHeader gets passed through
pagespeed AddResourceHeader "X-Foo" "Bar";
add_header "" "";
}
@@ -1742,8 +1581,6 @@ http {
pagespeed Library 43 1o978_K0_LNE5_ystNklf
http://www.modpagespeed.com/rewrite_javascript.js;
pagespeed RetainComment " google_ad_section*";
pagespeed PermitIdsForCssCombining "allowed-to-combine-1-*";
pagespeed PermitIdsForCssCombining "allowed-to-combine-2-*";
# Test proxying of non-.pagespeed. resources.
pagespeed MapProxyDomain http://localhost:@@PRIMARY_PORT@@/modpagespeed_http
@@ -1871,53 +1708,6 @@ http {
expires 5m;
}
location /mod_pagespeed_test/example.json {
expires 10m;
}
location /mod_pagespeed_test/ipro/cc200/ {
add_header "Cache-Control" "max-age=200";
}
location /mod_pagespeed_test/ipro/cc200p/ {
add_header "Cache-Control" "private, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200nc/ {
add_header "Cache-Control" "no-cache, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200ns/ {
add_header "Cache-Control" "no-store, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200nt/ {
add_header "Cache-Control" "no-transform, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200sma5/ {
add_header "Cache-Control" "s-maxage=5, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200sma50/ {
add_header "Cache-Control" "s-maxage=50, max-age=200";
}
location /mod_pagespeed_test/ipro/cc200sma50nsp/ {
add_header "Cache-Control" "s-maxage=50,max-age=200";
}
location /mod_pagespeed_test/ipro/cc9/ {
add_header "Cache-Control" "max-age=9";
}
location /mod_pagespeed_test/ipro/cc200cc9/ {
add_header "Cache-Control" "max-age=200, max-age=9";
}
location /mod_pagespeed_test/ipro/cc200sma50sma5/ {
add_header "Cache-Control" "max-age=200, s-maxage=50, s-maxage=5";
}
location /mod_pagespeed_test/ipro/cc200sma50cc9/ {
add_header "Cache-Control" "max-age=200, s-maxage=50, max-age=9";
}
location /mod_pagespeed_test/ipro/cc200sma50cc9nsp/ {
add_header "Cache-Control" "max-age=200,s-maxage=50,max-age=9";
}
location /mod_pagespeed_test/ipro/cc200sma50sma51/ {
add_header "Cache-Control" "max-age=200, s-maxage=50, s-maxage=51";
}
location /mod_pagespeed_test/ipro/wait/ {
# TODO(jmarantz): ModPagespeedInPlaceWaitForOptimized should be superfluous,
# or made equivalent to ModPagespeedInPlaceRewriteDeadlineMs -1, which waits
@@ -1958,16 +1748,14 @@ http {
}
location /mod_pagespeed_test/ipro/instant/deadline/ {
set $ps_deadline -1;
pagespeed ImageRecompressionQuality $ps_deadline;
pagespeed InPlaceRewriteDeadlineMs $ps_deadline;
pagespeed InPlaceRewriteDeadlineMs -1;
}
# Test to make sure that user-authenticated resources do not get cached and
# optimized.
location /mod_pagespeed_test/auth/ {
auth_basic "Restricted";
auth_basic_user_file "@@SERVER_ROOT@@/mod_pagespeed_test/auth/passwd.conf";
auth_basic_user_file "@@SERVER_ROOT@@mod_pagespeed_test/auth/passwd.conf";
}
location /mod_pagespeed_test/ipro/cookie/ {
@@ -2008,10 +1796,9 @@ http {
pagespeed FetchHttps enable;
location /mod_pagespeed_test/https_fetch/ {
pagespeed DisableFilters inline_images;
set $ps_gstatic "https://www.gstatic.com/psa/static";
pagespeed MapProxyDomain
http://localhost:@@PRIMARY_PORT@@/https_gstatic_dot_com
$ps_gstatic;
https://www.gstatic.com/psa/static;
}
location /mod_pagespeed_test/strip_subresource_hints/default/ {
@@ -2040,11 +1827,6 @@ http {
"http://$host:@@PRIMARY_PORT@@/mod_pagespeed_test/ipro/instant/"
"@@SERVER_ROOT@@/mod_pagespeed_test/ipro/instant/";
location /mod_pagespeed_test/public/ {
add_header "Cache-Control" "public, max-age=600";
pagespeed PreserveUrlRelativity off;
}
pagespeed EnableFilters remove_comments;
# Test LoadFromFile mapping by mapping one dir to another.
@@ -2058,6 +1840,7 @@ http {
"@@SERVER_ROOT@@/mod_pagespeed_test/load_from_file/file_dir/httponly/";
pagespeed LoadFromFileRuleMatch Disallow \.ssp.css$ps_dollar;
pagespeed LoadFromFileRuleMatch Allow exception\.ssp\.css$ps_dollar;
#charset koi8-r;
#access_log logs/host.access.log main;
@@ -2104,7 +1887,6 @@ http {
image/svg+xml svg svgz;
image/webp webp;
application/json json;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
+2 -6
View File
@@ -23,11 +23,9 @@
# Exits with status 2 if command line args are wrong.
#
# Usage:
# ./run_tests.sh primary_port secondary_port mod_pagespeed_dir ngx_binary
# pagespeed_test_host
# ./run_tests.sh primary_port secondary_port mod_pagespeed_dir pagespeed_test_host
# Example:
# ./run_tests.sh 8050 8051 /path/to/mod_pagespeed /path/to/nginx/binary
# selfsigned.modpagespeed.com
# ./run_tests.sh 8050 8051 /path/to/mod_pagespeed www.modpagespeed.com
#
# Normally we test only with the native fetcher off. Set
@@ -56,7 +54,6 @@ SECONDARY_PORT="$2"
MOD_PAGESPEED_DIR="$3"
NGINX_EXECUTABLE="$4"
PAGESPEED_TEST_HOST="$5"
CONTROLLER_PORT=8053
RCPORT1=9991
RCPORT2=9992
RCPORT3=9993
@@ -75,7 +72,6 @@ function run_test_checking_failure() {
NGINX_EXECUTABLE="$NGINX_EXECUTABLE" \
PAGESPEED_TEST_HOST="$PAGESPEED_TEST_HOST" \
RUN_TESTS="$RUN_TESTS" \
CONTROLLER_PORT="$CONTROLLER_PORT" \
RCPORT1="$RCPORT1" \
RCPORT2="$RCPORT2" \
RCPORT3="$RCPORT3" \
-28
View File
@@ -163,31 +163,3 @@
fun:_ZN3re23DFA10AddToQueueEPNS0_5WorkqEij
...
}
{
<re2 uninitialized value in optimized code>
Memcheck:Value8
fun:_ZNK3re210SparseSetTIvE8containsEi
...
}
{
<re2 uninitialized value in optimized code>
Memcheck:Cond
fun:_ZNK3re210SparseSetTIvE8containsEi
...
}
{
<re2 uninitialized value in optimized code>
Memcheck:Value8
fun:_ZNK3re211SparseArrayIiE9has_indexEi
...
}
{
<re2 uninitialized value in optimized code>
Memcheck:Cond
fun:_ZNK3re211SparseArrayIiE9has_indexEi
...
}