lib/rack/request.rb in rack-0.4.0 vs lib/rack/request.rb in rack-0.9.0

- old
+ new

@@ -111,20 +111,21 @@ @env["rack.request.form_input"] = @env["rack.input"] unless @env["rack.request.form_hash"] = Utils::Multipart.parse_multipart(env) @env["rack.request.form_vars"] = @env["rack.input"].read @env["rack.request.form_hash"] = Utils.parse_query(@env["rack.request.form_vars"]) + @env["rack.input"].rewind if @env["rack.input"].respond_to?(:rewind) end @env["rack.request.form_hash"] else {} end end # The union of GET and POST data. def params - self.GET.update(self.POST) + self.put? ? self.GET : self.GET.update(self.POST) rescue EOFError => e self.GET end # shortcut for request.params[key] @@ -201,9 +202,17 @@ if m [m[1], (m[2] || 1.0).to_f] else raise "Invalid value for Accept-Encoding: #{part.inspect}" end + end + end + + def ip + if addr = @env['HTTP_X_FORWARDED_FOR'] + addr.split(',').last.strip + else + @env['REMOTE_ADDR'] end end end end