Skip to content
This repository was archived by the owner on May 9, 2022. It is now read-only.

Commit b948841

Browse files
committed
bugfix: setting builtin request headers Depth, Destination, Overwrite, and Date via ngx.req.set_header() and etc might not take effect at least with ngx_http_dav_module. thanks Igor Clark for the report.
1 parent c966258 commit b948841

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

src/ngx_http_lua_headers_in.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@ static ngx_http_lua_set_header_t ngx_http_lua_set_handlers[] = {
128128
ngx_http_set_builtin_header },
129129
#endif
130130

131+
#if (NGX_HTTP_DAV)
132+
{ ngx_string("Depth"),
133+
offsetof(ngx_http_headers_in_t, depth),
134+
ngx_http_set_builtin_header },
135+
136+
{ ngx_string("Destination"),
137+
offsetof(ngx_http_headers_in_t, destination),
138+
ngx_http_set_builtin_header },
139+
140+
{ ngx_string("Overwrite"),
141+
offsetof(ngx_http_headers_in_t, overwrite),
142+
ngx_http_set_builtin_header },
143+
144+
{ ngx_string("Date"), offsetof(ngx_http_headers_in_t, date),
145+
ngx_http_set_builtin_header },
146+
#endif
147+
131148
{ ngx_string("Cookie"),
132149
0,
133150
ngx_http_set_cookie_header },

t/028-req-header.t

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use Test::Nginx::Socket::Lua;
88

99
repeat_each(2);
1010

11-
plan tests => repeat_each() * (2 * blocks() + 24);
11+
plan tests => repeat_each() * (2 * blocks() + 26);
1212

1313
#no_diff();
1414
#no_long_string();
@@ -1506,3 +1506,29 @@ If-None-Match: *
15061506
test
15071507
--- no_error_log
15081508
[error]
1509+
1510+
1511+
1512+
=== TEST 48: set the Destination request header for WebDav
1513+
--- config
1514+
location = /a.txt {
1515+
rewrite_by_lua_block {
1516+
ngx.req.set_header("Destination", "/b.txt")
1517+
}
1518+
dav_methods MOVE;
1519+
dav_access all:rw;
1520+
root html;
1521+
}
1522+
1523+
--- user_files
1524+
>>> a.txt
1525+
hello, world!
1526+
1527+
--- request
1528+
MOVE /a.txt
1529+
1530+
--- response_body
1531+
--- no_error_log
1532+
client sent no "Destination" header
1533+
[error]
1534+
--- error_code: 204

util/build2.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ time ngx-build $force $version \
5252
--add-module=$root/../redis2-nginx-module \
5353
--add-module=$root/t/data/fake-module \
5454
--with-http_gunzip_module \
55+
--with-http_dav_module \
5556
--with-select_module \
5657
--with-poll_module \
5758
$opts \

0 commit comments

Comments
 (0)