cope with Sinatra more aggressively trying to guess Content-Type
authorLunar <lunar@anargeek.net>
Wed, 13 Mar 2013 17:43:44 +0000 (18:43 +0100)
committerLunar <lunar@anargeek.net>
Thu, 14 Mar 2013 10:44:12 +0000 (11:44 +0100)
It looks like recent Sinatra are now trying to guess Content-Type more
aggressively when using attachment. So we now set Content-Length and
Content-Type before calling Sinatra's methods in Application#send_stored_file.

lib/coquelicot/app.rb

index 41f33c6..54e734c 100644 (file)
@@ -382,10 +382,10 @@ module Coquelicot
     end
 
     def send_stored_file(file)
-      last_modified file.created_at.httpdate
-      attachment file.meta['Filename']
       response['Content-Length'] = "#{file.meta['Length']}"
       response['Content-Type'] = file.meta['Content-Type'] || 'application/octet-stream'
+      last_modified file.created_at.httpdate
+      attachment file.meta['Filename']
       throw :halt, [200, file]
     end