Commit f3841743 by Jean-Philippe Doyle Committed by Mike Burns

Rely on URI content_type only when provided.

As described in #2118, `OpenURI::Meta#content_type` will return
`application/octet-stream` when no `content-type` header is set. Using
the original `meta` fixes this issue.
parent 7eb664f2
......@@ -28,9 +28,7 @@ module Paperclip
end
def content_type_from_content
if @content.respond_to?(:content_type)
@content.content_type
end
@content.meta["content-type"].presence
end
def filename_from_content_disposition
......
......@@ -3,10 +3,9 @@ require 'spec_helper'
describe Paperclip::HttpUrlProxyAdapter do
before do
@open_return = StringIO.new("xxx")
@open_return.stubs(:content_type).returns("image/png")
@open_return.stubs(:meta).returns({})
Paperclip::HttpUrlProxyAdapter.any_instance.
stubs(:download_content).returns(@open_return)
@open_return.stubs(:meta).returns("content-type" => "image/png")
Paperclip::HttpUrlProxyAdapter.any_instance.stubs(:download_content).
returns(@open_return)
Paperclip::HttpUrlProxyAdapter.register
end
......
......@@ -16,6 +16,8 @@ describe Paperclip::UriAdapter do
end
context "a new instance" do
let(:meta) { { "content-type" => "image/png" } }
before do
Paperclip::UriAdapter.any_instance.
stubs(:download_content).returns(@open_return)
......@@ -71,6 +73,7 @@ describe Paperclip::UriAdapter do
context "a directory index url" do
let(:content_type) { "text/html" }
let(:meta) { { "content-type" => "text/html" } }
before do
Paperclip::UriAdapter.any_instance.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment