upr.git  about / heads / tags
Upload Progress for Rack
blob a65a30fc084dcf87846ceb48df9637f0e7086fe2 766 bytes (raw)
$ git show HEAD:lib/upr/params.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
# -*- encoding: binary -*-
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

git clone https://yhbt.net/upr.git