@@ -4,6 +4,8 @@ static ngx_chain_t* ngx_http_redirectionio_body_filter_replace(struct REDIRECTIO
4
4
5
5
static void ngx_http_redirectionio_response_headers_cleanup (void * response_headers );
6
6
7
+ static ngx_int_t ngx_http_redirectionio_create_filter_body (ngx_http_request_t * r );
8
+
7
9
ngx_int_t ngx_http_redirectionio_match_on_response_status_header_filter (ngx_http_request_t * r ) {
8
10
ngx_http_redirectionio_ctx_t * ctx ;
9
11
ngx_http_redirectionio_conf_t * conf ;
@@ -34,7 +36,7 @@ ngx_int_t ngx_http_redirectionio_match_on_response_status_header_filter(ngx_http
34
36
35
37
r -> headers_out .status = redirect_status_code ;
36
38
37
- return ngx_http_special_response_handler ( r , r -> headers_out . status );
39
+ return ngx_http_redirectionio_headers_filter ( r );
38
40
}
39
41
40
42
ngx_int_t ngx_http_redirectionio_headers_filter (ngx_http_request_t * r ) {
@@ -99,7 +101,7 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
99
101
first_header = (struct REDIRECTIONIO_HeaderMap * )redirectionio_action_header_filter_filter (ctx -> action , first_header , r -> headers_out .status );
100
102
101
103
if (first_header == NULL ) {
102
- return ngx_http_next_header_filter (r );
104
+ return ngx_http_redirectionio_create_filter_body (r );
103
105
}
104
106
105
107
cln = ngx_pool_cleanup_add (r -> pool , 0 );
@@ -163,6 +165,22 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
163
165
first_header = first_header -> next ;
164
166
}
165
167
168
+ return ngx_http_redirectionio_create_filter_body (r );
169
+ }
170
+
171
+ static ngx_int_t ngx_http_redirectionio_create_filter_body (ngx_http_request_t * r ) {
172
+ ngx_http_redirectionio_ctx_t * ctx ;
173
+
174
+ ctx = ngx_http_get_module_ctx (r , ngx_http_redirectionio_module );
175
+
176
+ if (ctx == NULL ) {
177
+ return ngx_http_next_header_filter (r );
178
+ }
179
+
180
+ if (ctx -> action == NULL ) {
181
+ return ngx_http_next_header_filter (r );
182
+ }
183
+
166
184
// Create body filter
167
185
ctx -> body_filter = (struct REDIRECTIONIO_FilterBodyAction * )redirectionio_action_body_filter_create (ctx -> action , r -> headers_out .status );
168
186
0 commit comments