Skip to content

Commit 6802279

Browse files
committed
change exit status in body filter
1 parent e33f4a4 commit 6802279

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

src/ngx_http_lua_bodyfilterby.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ ngx_http_lua_body_filter_by_chunk(lua_State *L, ngx_http_request_t *r,
8787
ngx_chain_t *in)
8888
{
8989
ngx_int_t rc;
90-
ngx_chain_t *cl;
9190
u_char *err_msg;
9291
size_t len;
9392
#if (NGX_PCRE)
@@ -146,20 +145,8 @@ ngx_http_lua_body_filter_by_chunk(lua_State *L, ngx_http_request_t *r,
146145

147146
lua_settop(L, 0);
148147

149-
if (ctx->body_filter_aborted) {
150-
/* send last content */
151-
for (cl = in; cl->next; cl = cl->next) {
152-
/* do nothing */
153-
}
154-
/* make ngx_http_write_filter_module happy */
155-
cl->buf->last_buf = 1;
156-
157-
ctx->eof = 1;
158-
159-
return NGX_OK;
160-
}
161-
162-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
148+
if (ctx->body_filter_aborted || rc == NGX_ERROR
149+
|| rc >= NGX_HTTP_SPECIAL_RESPONSE) {
163150
return NGX_ERROR;
164151
}
165152

t/082-body-filter.t

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ log_level('debug');
1010

1111
repeat_each(2);
1212

13-
plan tests => repeat_each() * (blocks() * 3 + 11);
13+
plan tests => repeat_each() * (blocks() * 3 + 8);
1414

1515
#no_diff();
1616
no_long_string();
@@ -855,9 +855,7 @@ API disabled in the context of body_filter_by_lua*
855855
}
856856
--- request
857857
GET /t
858-
--- response_body
859-
111
860-
--- error_code: 200
858+
--- ignore_response
861859
--- no_error_log
862860
[error]
863861
[alert]
@@ -882,31 +880,3 @@ API disabled in the context of body_filter_by_lua*
882880
--- ignore_response
883881
--- error_log
884882
attempt to exit with the code not 444 or ngx.ERROR
885-
886-
887-
888-
=== TEST 29: in 2nd times
889-
--- config
890-
location = /t {
891-
content_by_lua_block {
892-
ngx.say("111")
893-
ngx.say("222")
894-
ngx.say("333")
895-
}
896-
897-
body_filter_by_lua_block {
898-
ngx.ctx.times = (ngx.ctx.times or 0) + 1
899-
if ngx.ctx.times == 2 then
900-
ngx.exit(444)
901-
end
902-
}
903-
}
904-
--- request
905-
GET /t
906-
--- response_body
907-
111
908-
222
909-
--- error_code: 200
910-
--- no_error_log
911-
[error]
912-
[alert]

0 commit comments

Comments
 (0)