Skip to content

Commit ff9dad6

Browse files
committed
Use redirectionio module in backend, fix body being sent multiple times
1 parent cc98e99 commit ff9dad6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/ngx_http_redirectionio_module_filter.c

+11-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ ngx_int_t ngx_http_redirectionio_body_filter(ngx_http_request_t *r, ngx_chain_t
156156

157157
// Skip if no need to filters body (no filter on body, or already filtered headers)
158158
if (ctx->should_filter_body == 0) {
159-
return ngx_http_next_body_filter(r, ctx->body_buffer);
159+
status = ngx_http_next_body_filter(r, ctx->body_buffer);
160+
ctx->body_buffer = NULL;
161+
162+
return status;
160163
}
161164

162165
// Get connection
@@ -176,15 +179,20 @@ ngx_int_t ngx_http_redirectionio_body_filter(ngx_http_request_t *r, ngx_chain_t
176179
}
177180

178181
if (status != NGX_OK) {
179-
return ngx_http_next_body_filter(r, ctx->body_buffer);
182+
status = ngx_http_next_body_filter(r, ctx->body_buffer);
183+
ctx->body_buffer = NULL;
184+
185+
return status;
180186
}
181187
}
182188

183189
// Check connection
184190
if (ctx->connection_error) {
185191
ngx_http_redirectionio_release_resource(conf->connection_pool, ctx, 1);
192+
status = ngx_http_next_body_filter(r, ctx->body_buffer);
193+
ctx->body_buffer = NULL;
186194

187-
return ngx_http_next_body_filter(r, ctx->body_buffer);
195+
return status;
188196
}
189197

190198
// Send only if ctx->body_buffer is not null

0 commit comments

Comments
 (0)