Skip to content

Commit

Permalink
Explicitly read as binary in multipart_body for Windows [#1065 state:…
Browse files Browse the repository at this point in the history
…resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
bryan-ash authored and josh committed Jan 13, 2009
1 parent d3107ce commit 5a43908
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/integration.rb
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand All @@ -21,7 +20,6 @@ def read

def teardown
TestController.last_request_parameters = nil
TestController.last_request_type = nil
end

test "parses single parameter" do
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5a43908

Please sign in to comment.