Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added more tests for Accept-Ranges and also fixed a bug when clearing…

… this header. thanks Bo Blangstrup.
  • Loading branch information...
commit 28c62d1d27081222f17bccdf3746f458613d537a 1 parent 7bba2a1
@agentzh agentzh authored
View
17 src/ngx_http_headers_more_headers_out.c
@@ -31,6 +31,9 @@ static ngx_int_t ngx_http_set_header_helper(ngx_http_request_t *r,
static ngx_int_t ngx_http_set_builtin_header(ngx_http_request_t *r,
ngx_http_headers_more_header_val_t *hv, ngx_str_t *value);
+static ngx_int_t ngx_http_set_accept_ranges_header(ngx_http_request_t *r,
+ ngx_http_headers_more_header_val_t *hv, ngx_str_t *value);
+
static ngx_int_t ngx_http_set_content_length_header(ngx_http_request_t *r,
ngx_http_headers_more_header_val_t *hv, ngx_str_t *value);
@@ -76,7 +79,7 @@ static ngx_http_headers_more_set_header_t ngx_http_headers_more_set_handlers[] =
{ ngx_string("Accept-Ranges"),
offsetof(ngx_http_headers_out_t, accept_ranges),
- ngx_http_set_builtin_header },
+ ngx_http_set_accept_ranges_header },
{ ngx_string("WWW-Authenticate"),
offsetof(ngx_http_headers_out_t, www_authenticate),
@@ -324,6 +327,18 @@ ngx_http_set_content_length_header(ngx_http_request_t *r, ngx_http_headers_more_
static ngx_int_t
+ngx_http_set_accept_ranges_header(ngx_http_request_t *r, ngx_http_headers_more_header_val_t *hv,
+ ngx_str_t *value)
+{
+ if (value->len == 0) {
+ r->allow_ranges = 0;
+ }
+
+ return ngx_http_set_builtin_header(r, hv, value);
+}
+
+
+static ngx_int_t
ngx_http_clear_content_length_header(ngx_http_request_t *r, ngx_http_headers_more_header_val_t *hv,
ngx_str_t *value)
{
View
31 t/bug.t
@@ -2,9 +2,9 @@
use Test::Nginx::Socket; # 'no_plan';
-repeat_each(2);
+#repeat_each(2);
-plan tests => 14 * repeat_each();
+plan tests => 20 * repeat_each();
no_diff;
@@ -118,3 +118,30 @@ html>
--- error_code: 206
--- SKIP
+
+
+=== TEST 7: Allow-Ranges
+--- config
+ location /index.html {
+ more_clear_headers 'Accept-Ranges';
+ }
+--- request
+ GET /index.html
+--- response_headers
+! Accept-Ranges
+--- response_body_like: It works
+
+
+
+=== TEST 8: clear hand-written Allow-Ranges headers
+--- config
+ location /index.html {
+ more_set_headers 'Accept-Ranges: bytes';
+ more_clear_headers 'Accept-Ranges';
+ }
+--- request
+ GET /index.html
+--- response_headers
+! Accept-Ranges
+--- response_body_like: It works
+
View
24 t/builtin.t
@@ -1,9 +1,9 @@
-# vi:filetype=perl
+# vi:filetype=
use lib 'lib';
use Test::Nginx::Socket; # 'no_plan';
-plan tests => 57;
+plan tests => 60;
no_diff;
@@ -317,3 +317,23 @@ hello
--- response_body
hello
+
+
+=== TEST 20: set Vary
+--- config
+ location /foo {
+ more_set_headers 'Vary: gbk';
+ echo hello;
+ }
+ location /len {
+ default_type 'text/plain';
+ more_set_headers 'Vary: hello';
+ proxy_pass http://127.0.0.1:$server_port/foo;
+ }
+--- request
+ GET /len
+--- response_headers
+Vary: hello
+--- response_body
+hello
+
View
2  t/sanity.t
@@ -1,4 +1,4 @@
-# vi:filetype=perl
+# vi:filetype=
use lib 'lib';
use Test::Nginx::Socket;
View
31 util/build.sh
@@ -3,17 +3,25 @@
# this file is mostly meant to be used by the author himself.
root=`pwd`
-cd ~/work
+#cd ~/work
version=$1
opts=$2
+target=$root/work/nginx
+
+if [ ! -d ./buildroot ]; then
+ mkdir ./buildroot || exit 1
+fi
+
+cd buildroot || exit 1
if [ ! -s "nginx-$version.tar.gz" ]; then
- wget "http://sysoev.ru/nginx/nginx-$version.tar.gz" -O nginx-$version.tar.gz || exit 1
- tar -xzvf nginx-$version.tar.gz || exit 1
- if [ "$version" = "0.8.41" ]; then
- cp $root/../no-pool-nginx/nginx-$version-no_pool.patch ./
- patch -p0 < nginx-$version-no_pool.patch || exit 1
+ if [ -f ~/work/nginx-$version.tar.gz ]; then
+ cp ~/work/nginx-$version.tar.gz ./ || exit 1
+ else
+ wget "http://sysoev.ru/nginx/nginx-$version.tar.gz" -O nginx-$version.tar.gz || exit 1
fi
+
+ tar -xzvf nginx-$version.tar.gz || exit 1
fi
#tar -xzvf nginx-$version.tar.gz || exit 1
@@ -21,8 +29,9 @@ fi
#patch -p0 < nginx-$version-no_pool.patch || exit 1
cd nginx-$version/
+
if [[ "$BUILD_CLEAN" -eq 1 || ! -f Makefile || "$root/config" -nt Makefile || "$root/util/build.sh" -nt Makefile ]]; then
- ./configure --prefix=/opt/nginx \
+ ./configure --prefix=$target \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
@@ -42,11 +51,11 @@ if [[ "$BUILD_CLEAN" -eq 1 || ! -f Makefile || "$root/config" -nt Makefile || "$
#--without-http_ssi_module # we cannot disable ssi because echo_location_async depends on it (i dunno why?!)
fi
-if [ -f /opt/nginx/sbin/nginx ]; then
- rm -f /opt/nginx/sbin/nginx
+if [ -f $target/sbin/nginx ]; then
+ rm -f $target/sbin/nginx
fi
-if [ -f /opt/nginx/logs/nginx.pid ]; then
- kill `cat /opt/nginx/logs/nginx.pid`
+if [ -f $target/logs/nginx.pid ]; then
+ kill `cat $target/logs/nginx.pid`
fi
make -j3 && make install
Please sign in to comment.
Something went wrong with that request. Please try again.