Added test cases for URI cleaning in the query part (Issue #429).
authorMatt Giuca <matt.giuca@gmail.com>
Wed, 15 Feb 2012 00:47:02 +0000 (11:47 +1100)
committerMatt Giuca <matt.giuca@gmail.com>
Wed, 15 Feb 2012 01:00:27 +0000 (12:00 +1100)
test_requests.py

index 2783a23..0b5edcc 100644 (file)
@@ -160,6 +160,29 @@ class RequestsTestSuite(TestSetup, unittest.TestCase):
         response = get(url)
         self.assertEqual(response.url, httpbin('get/' + path_unreserved))
 
+        # Re-run all of the same tests on the query part of the URI
+        query_fully_escaped = '%3Ca%25b%23c%2Fd%3E=%C3%98%20%C3%A5'
+        url = httpbin('get/?' + query_fully_escaped)
+        response = get(url)
+        self.assertEqual(response.url, httpbin('get/?' + query_fully_escaped))
+
+        query = u'<a%25b%23c%2Fd%3E=\u00d8 %C3%A5'
+        url = httpbin('get/?' + query)
+        response = get(url)
+        self.assertEqual(response.url, httpbin('get/?' + query_fully_escaped))
+
+        # The legal characters in query happens to be the same as in path
+        query_reserved = '!$&\'()*+,/:=@-._~'
+        url = httpbin('get/?' + query_reserved)
+        response = get(url)
+        self.assertEqual(response.url, httpbin('get/?' + query_reserved))
+
+        query_unreserved = 'ABCDwxyz=1234-._~'
+        query_unreserved_escaped = '%41%42%43%44%77%78%79%7A=%31%32%33%34%2D%2E%5F%7E'
+        url = httpbin('get/?' + query_unreserved_escaped)
+        response = get(url)
+        self.assertEqual(response.url, httpbin('get/?' + query_unreserved))
+
 
     def test_user_agent_transfers(self):
         """Issue XX"""