Permalink
Browse files

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...
1 parent 7842980 commit 9b46f693819008f16cfe319e3dbe7f9d67cd2083 @dhh dhh committed Feb 25, 2007
View
@@ -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+$/ }
@@ -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'
)
@@ -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
@@ -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'
}
@@ -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']

0 comments on commit 9b46f69

Please sign in to comment.