Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Explicitly read as binary in multipart_body for Windows [#1065 state:…

…resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
commit 5a43908c7414996354ca427354d98d789e0210e7 1 parent d3107ce
Bryan Ash bryan-ash authored josh committed
2  actionpack/lib/action_controller/integration.rb
View
@@ -431,7 +431,7 @@ def multipart_requestify(params, first=true)
def multipart_body(params, boundary)
multipart_requestify(params).map do |key, value|
if value.respond_to?(:original_filename)
- File.open(value.path) do |f|
+ File.open(value.path, "rb") do |f|
f.set_encoding(Encoding::BINARY) if f.respond_to?(:set_encoding)
<<-EOF
14 actionpack/test/controller/request/multipart_params_parsing_test.rb
View
@@ -3,11 +3,10 @@
class MultipartParamsParsingTest < ActionController::IntegrationTest
class TestController < ActionController::Base
class << self
- attr_accessor :last_request_parameters, :last_request_type
+ attr_accessor :last_request_parameters
end
def parse
- self.class.last_request_type = ActionController::Base.param_parsers[request.content_type]
self.class.last_request_parameters = request.request_parameters
head :ok
end
@@ -21,7 +20,6 @@ def read
def teardown
TestController.last_request_parameters = nil
- TestController.last_request_type = nil
end
test "parses single parameter" do
@@ -103,11 +101,13 @@ def teardown
assert_equal 19756, files.size
end
- test "uploads and parses parameters" do
+ test "uploads and reads binary file" do
with_test_routing do
- params = { :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/mona_lisa.jpg", "image/jpg") }
- post '/parse', params, :location => 'blah'
- assert_equal(:multipart_form, TestController.last_request_type)
+ fixture = FIXTURE_PATH + "/mona_lisa.jpg"
+ params = { :uploaded_data => fixture_file_upload(fixture, "image/jpg") }
+ post '/read', params
+ expected_length = 'File: '.length + File.size(fixture)
+ assert_equal expected_length, response.content_length
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.