Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow send_file/send_data to use a registered mime type as the :type …
…parameter #7620 [jonathan]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6233 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Feb 25, 2007
1 parent 7842980 commit 9b46f69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Allow send_file/send_data to use a registered mime type as the :type parameter #7620 [jonathan]

* Allow routing requirements on map.resource(s) #7633 [quixoten]. Example:

map.resources :network_interfaces, :requirements => { :id => /^\d+\.\d+\.\d+\.\d+$/ }
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/streaming.rb
Expand Up @@ -124,7 +124,7 @@ def send_file_headers!(options)

headers.update(
'Content-Length' => options[:length],
'Content-Type' => options[:type].strip, # fixes a problem with extra '\r' with some browsers
'Content-Type' => options[:type].to_s.strip, # fixes a problem with extra '\r' with some browsers
'Content-Disposition' => disposition,
'Content-Transfer-Encoding' => 'binary'
)
Expand Down
6 changes: 4 additions & 2 deletions actionpack/test/controller/send_file_test.rb
Expand Up @@ -26,6 +26,8 @@ def rescue_action(e) raise end
class SendFileTest < Test::Unit::TestCase
include TestFileUtils

Mime::Type.register "image/png", :png unless defined? Mime::PNG

def setup
@controller = SendFileController.new
@request = ActionController::TestRequest.new
Expand Down Expand Up @@ -83,7 +85,7 @@ def test_headers_after_send_shouldnt_include_charset
def test_send_file_headers!
options = {
:length => 1,
:type => 'type',
:type => Mime::PNG,
:disposition => 'disposition',
:filename => 'filename'
}
Expand All @@ -98,7 +100,7 @@ def test_send_file_headers!

h = @controller.headers
assert_equal 1, h['Content-Length']
assert_equal 'type', h['Content-Type']
assert_equal 'image/png', h['Content-Type']
assert_equal 'disposition; filename="filename"', h['Content-Disposition']
assert_equal 'binary', h['Content-Transfer-Encoding']

Expand Down

0 comments on commit 9b46f69

Please sign in to comment.