提交 796049ef 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #26551 from mgpnd/FixContentLength

Fixed CONTENT_LENGTH header in ActionController::TestRequest
......@@ -112,8 +112,9 @@ def assign_parameters(routes, controller_path, action, parameters, generated_pat
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|
......
......@@ -11,6 +11,16 @@ def test_mutating_session_options_does_not_affect_default_options
assert_equal nil, ActionController::TestSession::DEFAULT_OPTIONS[:myparam]
end
def test_content_length_has_bytes_count_value
non_ascii_parameters = { data: { content: "Latin + Кириллица" } }
@request.set_header "REQUEST_METHOD", "POST"
@request.set_header "CONTENT_TYPE", "application/json"
@request.assign_parameters(@routes, "test", "create", non_ascii_parameters,
"/test", [:data, :controller, :action])
assert_equal(@request.get_header("CONTENT_LENGTH"),
StringIO.new(non_ascii_parameters.to_json).length.to_s)
end
ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS.each_key do |option|
test "rack default session options #{option} exists in session options and is default" do
assert_equal(ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS[option],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册