@@ -537,9 +537,23 @@ ngx_http_modsecurity_save_request_body(ngx_http_request_t *r)
537
537
buf -> last += content_length ;
538
538
r -> header_in = buf ;
539
539
540
+ if (r -> headers_in .content_length ) {
541
+ ngx_str_t * str = NULL ;
542
+
543
+ str = & r -> headers_in .content_length -> value ;
544
+ str -> data = ngx_palloc (r -> pool , NGX_OFF_T_LEN );
545
+ if (str -> data == NULL ) {
546
+ ngx_http_finalize_request (r , NGX_HTTP_INTERNAL_SERVER_ERROR );
547
+ return NGX_OK ;
548
+ }
549
+ str -> len = ngx_snprintf (str -> data , NGX_OFF_T_LEN , "%O" , content_length ) - str -> data ;
550
+
551
+ }
552
+
553
+
540
554
r -> headers_in .content_length_n = content_length ;
541
555
542
- ngx_log_debug (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 , "ModSec: Content length: %O, Content length n: %O" , content_length , r -> headers_in .content_length_n );
556
+ ngx_log_debug (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 , "ModSec: Content length: %O, Content length n: %O" , content_length , r -> headers_in .content_length_n );
543
557
return NGX_OK ;
544
558
}
545
559
@@ -635,7 +649,7 @@ ngx_http_modsecurity_load_headers_out(ngx_http_request_t *r)
635
649
* (const char * * )apr_array_push (ctx -> req -> content_languages ) = data ;
636
650
}
637
651
638
- /* req->chunked = r->chunked; may be useless */
652
+ req -> chunked = r -> chunked ;
639
653
req -> clength = r -> headers_out .content_length_n ;
640
654
req -> mtime = apr_time_make (r -> headers_out .last_modified_time , 0 );
641
655
@@ -654,7 +668,7 @@ ngx_http_modsecurity_save_headers_out(ngx_http_request_t *r)
654
668
655
669
ctx = ngx_http_get_module_ctx (r , ngx_http_modsecurity );
656
670
657
- /* r->chunked = ctx->req->chunked; */
671
+ r -> chunked = ctx -> req -> chunked ;
658
672
659
673
ngx_http_clean_header (r );
660
674
@@ -1055,7 +1069,6 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r) {
1055
1069
1056
1070
return NGX_DECLINED ;
1057
1071
}
1058
-
1059
1072
if (ctx -> waiting_more_body == 1 ) {
1060
1073
ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
1061
1074
"ModSec: waiting for more data before proceed. / count: %d" , r -> main -> count );
@@ -1068,6 +1081,8 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r) {
1068
1081
"ModSec: asking for the request body, if any." );
1069
1082
1070
1083
ctx -> body_requested = 1 ;
1084
+ r -> request_body_in_single_buf = 1 ;
1085
+
1071
1086
rc = ngx_http_read_client_request_body (r ,
1072
1087
ngx_http_modsecurity_request_read );
1073
1088
@@ -1084,8 +1099,11 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r) {
1084
1099
}
1085
1100
1086
1101
if (ctx -> waiting_more_body == 0 && ctx -> request_processed == 0 ) {
1102
+
1087
1103
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
1088
1104
"ModSec: request is ready to be processed." );
1105
+ ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
1106
+ "ModSec: chuncked? %d" , r -> chunked );
1089
1107
ngx_http_modsecurity_process_request (r );
1090
1108
ctx -> request_processed = 1 ;
1091
1109
}
@@ -1287,6 +1305,8 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
1287
1305
}
1288
1306
1289
1307
return ngx_http_next_body_filter (r , out );
1308
+
1309
+ return NGX_OK ;
1290
1310
}
1291
1311
#endif
1292
1312
0 commit comments