Skip to content

Commit 03a2fd2

Browse files
committed
do not send empty chain link in echo_after_body because it may trigger the infamous "the http output chain is empty" alert in error.log when the standard ngx_ssi module is disabled. thanks Sparsh Gupta.
1 parent 4d6acc9 commit 03a2fd2

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

src/ngx_http_echo_echo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ ngx_http_echo_exec_echo_sync(ngx_http_request_t *r,
6666
if (cl == NULL) {
6767
return NGX_HTTP_INTERNAL_SERVER_ERROR;
6868
}
69+
6970
cl->buf = buf;
7071
cl->next = NULL;
7172

src/ngx_http_echo_filter.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ ngx_http_echo_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
138138

139139
prev = NULL;
140140
for (cl = in; cl; prev = cl, cl = cl->next) {
141+
dd("prev %p, cl %p, special %d", prev, cl, ngx_buf_special(cl->buf));
142+
141143
if (cl->buf->last_buf) {
142144
if (ngx_buf_special(cl->buf)) {
143145
if (prev) {
@@ -155,12 +157,16 @@ ngx_http_echo_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
155157
}
156158
}
157159

158-
rc = ngx_http_echo_next_body_filter(r, in);
160+
dd("in %p, last %d", in, (int) last);
159161

160-
dd("next filter returns %d, last %d", (int) rc, (int) last);
162+
if (in) {
163+
rc = ngx_http_echo_next_body_filter(r, in);
161164

162-
if (rc == NGX_ERROR || rc > NGX_OK || !last) {
163-
return rc;
165+
dd("next filter returns %d, last %d", (int) rc, (int) last);
166+
167+
if (rc == NGX_ERROR || rc > NGX_OK || !last) {
168+
return rc;
169+
}
164170
}
165171

166172
dd("exec filter cmds for after body cmds");

t/echo-after-body.t

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,21 @@ hello
208208
hello
209209
--- SKIP
210210

211+
212+
213+
=== TEST 13: echo_after_body + lua output
214+
--- config
215+
gzip on;
216+
gzip_min_length 1;
217+
location /main {
218+
echo_after_body 'world';
219+
proxy_pass http://127.0.0.1:$server_port/foo;
220+
}
221+
location /foo {
222+
echo hello;
223+
}
224+
--- request
225+
GET /main
226+
--- response_body_like
227+
hello
228+

util/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version=$1
77
force=$2
88
home=~
99

10+
#--without-http_ssi_module \
1011
ngx-build $force $version \
1112
--with-cc-opt="-DDEBUG_MALLOC" \
1213
--with-http_stub_status_module \
@@ -35,5 +36,4 @@ ngx-build $force $version \
3536
#--add-module=$home/work/ndk/examples/http/set_var \
3637
#--add-module=$root/../eval-nginx-module \
3738
#--add-module=/home/agentz/work/nginx_eval_module-1.0.1 \
38-
#--without-http_ssi_module # we cannot disable ssi because echo_location_async depends on it (i dunno why?!)
3939

0 commit comments

Comments
 (0)