aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorArtem Rashev <stillintop@gmail.com>2016-09-19 21:54:23 +0300
committerArtem Rashev <stillintop@gmail.com>2016-11-15 12:50:38 +0300
commitb388ca41d8b26f027a43e96c5ad0950a6bf2f5d7 (patch)
tree2b94cae7715eadb1d74654bbc6df31526aa5b73b /actionpack/lib
parent3a558aa2bc8ce3834ee79ff3346bcf5d7debbbd0 (diff)
downloadrails-b388ca41d8b26f027a43e96c5ad0950a6bf2f5d7.tar.gz
rails-b388ca41d8b26f027a43e96c5ad0950a6bf2f5d7.tar.bz2
rails-b388ca41d8b26f027a43e96c5ad0950a6bf2f5d7.zip
Fixed CONTENT_LENGTH header in ActionController::TestRequest
CONENT_LENGTH setted by string length, which is equal to number of characters in string but StringIO.length is byte sequence and when payload contains non-ASCII characters, stream's length will be different. That's why real byte length should be used for CONTENT_LENGTH header. Add unit test for CONTENT_LENGTH header fix It just passes non-ascii symbols as parameters and verifies that "CONTENT_LENGTH" header has content bytes count as value.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/test_case.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 33c0201951..85f2501d42 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -112,8 +112,9 @@ module ActionController
end
end
- set_header "CONTENT_LENGTH", data.length.to_s
- set_header "rack.input", StringIO.new(data)
+ data_stream = StringIO.new(data)
+ set_header "CONTENT_LENGTH", data_stream.length.to_s
+ set_header "rack.input", data_stream
end
fetch_header("PATH_INFO") do |k|