diff options
Diffstat (limited to 'lib/upr/params.rb')
-rw-r--r-- | lib/upr/params.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/upr/params.rb b/lib/upr/params.rb new file mode 100644 index 0000000..3babdc0 --- /dev/null +++ b/lib/upr/params.rb @@ -0,0 +1,23 @@ +require 'rack' + +module Upr + + module Params + + # we'll add compatibility for existing upload progress modules + # we find here, but under no circumstances will we help + # proliferate new and subtly incompatible mechanisms. + # X-Progress-ID is used in both lighttpd and nginx (3rd party module) + # "upload_id" is used by mongrel_upload_progress + def extract_upload_id(env) + upid = env['HTTP_X_PROGRESS_ID'] and return upid + + # can't blindly parse params here since we don't want to read + # the POST body if there is one, so only parse stuff in the + # query string... + params = Rack::Request.new(env).GET + env["upr.upload_id"] = params["X-Progress-ID"] || params["upload_id"] + end + + end +end |