about summary refs log tree commit homepage
path: root/lib/upr/input_wrapper.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-12 13:32:56 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-12 13:36:31 -0800
commitf301f399937f9ff62dc41a9cd8e1ea45b43baa6b (patch)
treee2345c94b1eba47f79b00f0251c7375b81a702a0 /lib/upr/input_wrapper.rb
parente71a98deacd25bfaad5b80b0cd505e183933010c (diff)
downloadupr-f301f399937f9ff62dc41a9cd8e1ea45b43baa6b.tar.gz
Split out Params and StatusMethods
StatusMethods will be reusable in subclasses like the
UprStatus ActiveRecord class.  Params parsing will be
common to both InputWrapper and also to the upcoming
Streaming class.
Diffstat (limited to 'lib/upr/input_wrapper.rb')
-rw-r--r--lib/upr/input_wrapper.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/upr/input_wrapper.rb b/lib/upr/input_wrapper.rb
index 2070d38..5268498 100644
--- a/lib/upr/input_wrapper.rb
+++ b/lib/upr/input_wrapper.rb
@@ -9,6 +9,8 @@ module Upr
                                   :input, :pos, :seen, :content_length,
                                   :upload_id, :mtime)
 
+    include Params
+
     def initialize(app, options = {})
       super(app,
             Array(options[:path_info] || nil),
@@ -38,12 +40,7 @@ module Upr
         length = env["CONTENT_LENGTH"] and length = length.to_i
         env["TRANSFER_ENCODING"] =~ %r{\Achunked\z}i and length = nil
         if length.nil? || length > 0
-          req = Rack::Request.new(env)
-
-          # 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...
-          if uid = req.GET["upload_id"]
+          if uid = extract_upload_id(env)
             return dup._call(env, uid, length)
           end
         end
@@ -52,7 +49,7 @@ module Upr
     end
 
     def _call(env, uid, length)
-      self.upload_id = env["upr.upload_id"] = uid
+      self.upload_id = uid
       self.mtime = self.pos = self.seen = 0
       self.input = env["rack.input"]
       env["rack.input"] = self