Added ability to check if missing trailing slash in path.
authorBrendon Crawford <brendon@aphexcreations.net>
Mon, 30 Jan 2012 07:24:54 +0000 (23:24 -0800)
committerBrendon Crawford <brendon@aphexcreations.net>
Mon, 30 Jan 2012 07:24:54 +0000 (23:24 -0800)
Previously this URL would not work:

    http://example.com?foo=bar

But this URL would work:

    http://example.com/?foo=bar

Even though a slash is required for a valid URL, it is a common use case
for the slash to be left out, so it would be a good idea to account for this.

requests/models.py

index 7ac85cc09b087d2efac69d33e5f74f16b2431f7e..6fdf8bb0a82133289183a7f09895d5c376b793f9 100644 (file)
@@ -317,6 +317,9 @@ class Request(object):
 
         netloc = netloc.encode('idna').decode('utf-8')
 
+        if not path:
+            path = '/'
+
         if is_py2:
             if isinstance(path, str):
                 path = path.encode('utf-8')