summary refs log tree commit
path: root/lib/rack/mock.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rack/mock.rb')
-rw-r--r--lib/rack/mock.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/rack/mock.rb b/lib/rack/mock.rb
index 3ba314e4..3c02c1fe 100644
--- a/lib/rack/mock.rb
+++ b/lib/rack/mock.rb
@@ -77,9 +77,16 @@ module Rack
       body.close if body.respond_to?(:close)
     end
 
+    # For historical reasons, we're pinning to RFC 2396. It's easier for users
+    # and we get support from ruby 1.8 to 2.2 using this method.
+    def self.parse_uri_rfc2396(uri)
+      @parser ||= defined?(URI::RFC2396_Parser) ? URI::RFC2396_Parser.new : URI
+      @parser.parse(uri)
+    end
+
     # Return the Rack environment used for a request to +uri+.
     def self.env_for(uri="", opts={})
-      uri = URI(uri)
+      uri = parse_uri_rfc2396(uri)
       uri.path = "/#{uri.path}" unless uri.path[0] == ?/
 
       env = DEFAULT_ENV.dup