@@ -57,6 +57,8 @@ ngx_int_t ngx_http_redirectionio_match_on_response_status_header_filter(ngx_http
5757 // Avoid loop if we redirect on the same status as we match
5858 ctx -> is_redirected = 1 ;
5959
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
6062 return ngx_http_special_response_handler (r , ctx -> status );
6163}
6264
@@ -142,6 +144,10 @@ ngx_int_t ngx_http_redirectionio_body_filter(ngx_http_request_t *r, ngx_chain_t
142144 return ngx_http_next_body_filter (r , in );
143145 }
144146
147+ if (ctx -> body_sent ) {
148+ return NGX_OK ;
149+ }
150+
145151 // Check if we are waiting for filtering headers or connection
146152 if (ctx -> wait_for_header_filtering || ctx -> wait_for_connection ) {
147153 // 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
219225 ngx_http_request_t * r ;
220226 ngx_http_redirectionio_conf_t * conf ;
221227 ngx_chain_t * cl ;
228+ ngx_uint_t last ;
222229
223230 c = wev -> data ;
224231 r = c -> data ;
@@ -240,7 +247,11 @@ static void ngx_http_redirectionio_write_filter_body_handler(ngx_event_t *wev, n
240247 ctx -> last_chain_sent = in ;
241248 ctx -> read_binary_handler = ngx_http_redirectionio_read_filter_body_handler ;
242249
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+ }
244255}
245256
246257static void ngx_http_redirectionio_read_filter_headers_handler (ngx_event_t * rev , cJSON * json ) {
0 commit comments