gist: 3261 Download_button fork
public
Public Clone URL: git://gist.github.com/3261.git
example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'rubygems'
$:.unshift "sinatra/lib"
require "sinatra"
 
get "/form" do
  haml %{
%form.song{:action => "/songs", :method => "post", :enctype=>"multipart/form-data"}
  /%input{:type=>"text", :name => "url"}
  %input{:type=>"file", :name => "file"}
  %input{:type=>"submit", :value=> ">"}
}
end
 
post "/songs" do
  redirect "/form"
end
 
patch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
index b02786d..d3bdc68 100755
--- a/lib/sinatra.rb
+++ b/lib/sinatra.rb
@@ -1235,7 +1235,13 @@ module Sinatra
         body = returned.to_result(context)
       end
       body = '' unless body.respond_to?(:each)
- body = '' if request.request_method.upcase == 'HEAD'
+
+# Using request.env["REQUEST_METHOD"].upcase instead of:
+# request.request_method because it failed silently
+# in the example: http://gist.github.com/3261
+# when uploading a file matching "*.mp3"
+ body = '' if request.env["REQUEST_METHOD"].upcase == 'HEAD'
+
       context.body = body.kind_of?(String) ? [*body] : body
       context.finish
     end
Text only
1
Strangly, this breaks with Mongrel when uploading a matching "*.mp3" (possibly others)

Owner

collin

Revisions