File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
actionpack/lib/action_dispatch/http Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 413
413
pg (>= 1.1 , < 2.0 )
414
414
raabro (1.4.0 )
415
415
racc (1.8.0 )
416
- rack (3.0.11 )
416
+ rack (3.1.3 )
417
417
rack-cache (1.15.0 )
418
418
rack (>= 0.4 )
419
419
rack-session (2.0.0 )
Original file line number Diff line number Diff line change @@ -340,7 +340,6 @@ def server_software
340
340
def raw_post
341
341
unless has_header? "RAW_POST_DATA"
342
342
set_header ( "RAW_POST_DATA" , read_body_stream )
343
- body_stream . rewind if body_stream . respond_to? ( :rewind )
344
343
end
345
344
get_header "RAW_POST_DATA"
346
345
end
@@ -467,9 +466,27 @@ def default_session
467
466
end
468
467
469
468
def read_body_stream
470
- body_stream . rewind if body_stream . respond_to? ( :rewind )
471
- return body_stream . read if headers . key? ( "Transfer-Encoding" ) # Read body stream until EOF if "Transfer-Encoding" is present
472
- body_stream . read ( content_length )
469
+ reset_stream ( body_stream ) do
470
+ if headers . key? ( "Transfer-Encoding" )
471
+ body_stream . read # Read body stream until EOF if "Transfer-Encoding" is present
472
+ else
473
+ body_stream . read ( content_length )
474
+ end
475
+ end
476
+ end
477
+
478
+ def reset_stream ( body_stream )
479
+ if body_stream . respond_to? ( :rewind )
480
+ body_stream . rewind
481
+
482
+ content = yield
483
+
484
+ body_stream . rewind
485
+
486
+ content
487
+ else
488
+ yield
489
+ end
473
490
end
474
491
end
475
492
end
You can’t perform that action at this time.
0 commit comments