Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bugfix: more_set_input_headers did not handle the Accept-Encoding req…

…uest headers properly. thanks 天街夜色.
  • Loading branch information...
commit 9161a993beb0b4fdc66c9c6846170fe7949bf930 1 parent 29e8b41
@agentzh agentzh authored
View
9 src/ngx_http_lua_headers_in.c
@@ -1,8 +1,9 @@
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */
/* Copyright (C) agentzh */
+#ifndef DDEBUG
#define DDEBUG 0
-
+#endif
#include "ddebug.h"
#include <nginx.h>
@@ -42,6 +43,12 @@ static ngx_int_t ngx_http_lua_rm_header(ngx_list_t *l, ngx_table_elt_t *h);
static ngx_http_lua_set_header_t ngx_http_lua_set_handlers[] = {
+#if (NGX_HTTP_GZIP)
+ { ngx_string("Accept-Encoding"),
+ offsetof(ngx_http_headers_in_t, accept_encoding),
+ ngx_http_set_builtin_header },
+#endif
+
{ ngx_string("Host"),
offsetof(ngx_http_headers_in_t, host),
ngx_http_set_host_header },
View
2  t/016-resp-header.t
@@ -7,7 +7,7 @@ use Test::Nginx::Socket;
#master_process_enabled(1);
#log_level('warn');
-#repeat_each(2);
+repeat_each(2);
plan tests => blocks() * repeat_each() * 3;
View
25 t/028-req-header.t
@@ -10,7 +10,7 @@ use Test::Nginx::Socket;
repeat_each(2);
#repeat_each(1);
-plan tests => blocks() * repeat_each() * 2;
+plan tests => (2 * blocks() + 1) * repeat_each();
#no_diff();
#no_long_string();
@@ -335,3 +335,26 @@ value is of type table.
Foo takes 3 values.
They are foo, bar, baz.
+
+
+=== TEST 17: Accept-Encoding
+--- config
+ location /bar {
+ default_type 'text/plain';
+ rewrite_by_lua '
+ ngx.req.set_header("Accept-Encoding", "gzip")
+ ';
+ gzip on;
+ gzip_min_length 1;
+ gzip_buffers 4 8k;
+ gzip_types text/plain;
+ }
+--- user_files
+">>> bar
+" . ("hello" x 512)
+--- request
+GET /bar
+--- response_headers
+Content-Encoding: gzip
+--- response_body_like: .{20}
+
Please sign in to comment.
Something went wrong with that request. Please try again.