Skip to content

Commit 0d60a48

Browse files
committed
fix(body-filter): discard buffer from nginx when the body has already been filtered
1 parent 14e670f commit 0d60a48

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ngx_http_redirectionio_module_filter.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ ngx_int_t ngx_http_redirectionio_body_filter(ngx_http_request_t *r, ngx_chain_t
260260

261261
// Buffered case
262262
if (tmp_chain == NULL) {
263+
if (ctx->body_filter == NULL) {
264+
// Case where the body filter has been closed and we receive NULL, which means we have to send the last buffer as last
265+
last_chain->buf->last_buf = 1;
266+
break;
267+
}
268+
263269
// Update sent chain
264270
previous_chain = current_chain;
265271
tsize += ngx_buf_size(current_chain->buf);
@@ -363,7 +369,7 @@ static ngx_chain_t* ngx_http_redirectionio_body_filter_replace(ngx_http_redirect
363369
return out;
364370
}
365371

366-
return cl;
372+
return NULL;
367373
}
368374

369375
mbsize = buf_out.len;

0 commit comments

Comments
 (0)