@@ -1077,16 +1077,17 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r) {
1077
1077
const char * location ;
1078
1078
ngx_table_elt_t * h ;
1079
1079
ngx_int_t rc ;
1080
-
1080
+
1081
1081
1082
1082
cf = ngx_http_get_module_loc_conf (r , ngx_http_modsecurity );
1083
1083
ctx = ngx_http_get_module_ctx (r , ngx_http_modsecurity );
1084
1084
1085
+ /* already processed, checking redirect action. */
1085
1086
if (ctx && ctx -> complete
1086
1087
&& r -> err_status >= NGX_HTTP_MOVED_PERMANENTLY
1087
1088
&& r -> err_status < 308 ) {
1088
1089
1089
- /* 3XX load redirect location header so that we can do redirec in phase 3,4 */
1090
+ /* 3XX load redirect location header so that we can do redirect in phase 3,4 */
1090
1091
location = apr_table_get (ctx -> req -> headers_out , "Location" );
1091
1092
1092
1093
if (location == NULL ) {
@@ -1113,7 +1114,8 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r) {
1113
1114
1114
1115
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 , "modSecurity: header filter" );
1115
1116
1116
- if (r -> method == NGX_HTTP_HEAD || r -> header_only ) {
1117
+ /* header only or SecResponseBodyAccess off */
1118
+ if (r -> header_only || (!modsecIsResponseBodyAccessEnabled (ctx -> req )) ) {
1117
1119
1118
1120
ctx -> complete = 1 ;
1119
1121
@@ -1126,17 +1128,18 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r) {
1126
1128
rc = ngx_http_modsecurity_status (r , modsecProcessResponse (ctx -> req ));
1127
1129
1128
1130
if (rc != NGX_DECLINED ) {
1129
- return rc ;
1131
+ return ngx_http_filter_finalize_request ( r , & ngx_http_modsecurity , rc ) ;
1130
1132
}
1131
1133
1132
1134
if (ngx_http_modsecurity_save_headers_in (r ) != NGX_OK
1133
1135
|| ngx_http_modsecurity_save_headers_out (r ) != NGX_OK ) {
1134
- return NGX_HTTP_INTERNAL_SERVER_ERROR ;
1136
+ return ngx_http_filter_finalize_request ( r , & ngx_http_modsecurity , NGX_HTTP_INTERNAL_SERVER_ERROR ) ;
1135
1137
}
1136
1138
1137
1139
return ngx_http_next_header_filter (r );
1138
1140
}
1139
1141
1142
+ /* SecResponseBodyAccess on, process rules in body filter */
1140
1143
return NGX_OK ;
1141
1144
}
1142
1145
0 commit comments