@@ -57,6 +57,8 @@ ngx_int_t ngx_http_redirectionio_match_on_response_status_header_filter(ngx_http
57
57
// Avoid loop if we redirect on the same status as we match
58
58
ctx -> is_redirected = 1 ;
59
59
60
+ // @TODO This will made a double body response (one from nginx / one from upstream)
61
+ // @TODO Find a way to cancel the current body response
60
62
return ngx_http_special_response_handler (r , ctx -> status );
61
63
}
62
64
@@ -142,6 +144,10 @@ ngx_int_t ngx_http_redirectionio_body_filter(ngx_http_request_t *r, ngx_chain_t
142
144
return ngx_http_next_body_filter (r , in );
143
145
}
144
146
147
+ if (ctx -> body_sent ) {
148
+ return NGX_OK ;
149
+ }
150
+
145
151
// Check if we are waiting for filtering headers or connection
146
152
if (ctx -> wait_for_header_filtering || ctx -> wait_for_connection ) {
147
153
// Set request is buffered to avoid its destruction by nginx
@@ -219,6 +225,7 @@ static void ngx_http_redirectionio_write_filter_body_handler(ngx_event_t *wev, n
219
225
ngx_http_request_t * r ;
220
226
ngx_http_redirectionio_conf_t * conf ;
221
227
ngx_chain_t * cl ;
228
+ ngx_uint_t last ;
222
229
223
230
c = wev -> data ;
224
231
r = c -> data ;
@@ -240,7 +247,11 @@ static void ngx_http_redirectionio_write_filter_body_handler(ngx_event_t *wev, n
240
247
ctx -> last_chain_sent = in ;
241
248
ctx -> read_binary_handler = ngx_http_redirectionio_read_filter_body_handler ;
242
249
243
- ngx_http_redirectionio_protocol_send_filter_body (c , in , & conf -> project_key , & ctx -> matched_rule_id , is_first );
250
+ last = ngx_http_redirectionio_protocol_send_filter_body (c , in , & conf -> project_key , & ctx -> matched_rule_id , is_first );
251
+
252
+ if (last == 1 ) {
253
+ ctx -> body_sent = 1 ;
254
+ }
244
255
}
245
256
246
257
static void ngx_http_redirectionio_read_filter_headers_handler (ngx_event_t * rev , cJSON * json ) {
0 commit comments