Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'=' char is now safe in urls; wss:// protocol is now safe #477

Merged
merged 1 commit into from
Aug 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def update_host(self, url):
self.netloc = netloc

scheme = url_parsed.scheme
self.ssl = scheme == 'https'
self.ssl = scheme in ('https', 'wss')

# set port number if it isn't already set
if not port:
Expand Down Expand Up @@ -175,7 +175,7 @@ def update_path(self, params):
query = params

self.path = urllib.parse.urlunsplit(
('', '', urllib.parse.quote(path, safe='/%:'), query, fragment))
('', '', urllib.parse.quote(path, safe='/%:='), query, fragment))
self.url = urllib.parse.urlunsplit(
(scheme, netloc, self.path, '', ''))

Expand Down
19 changes: 19 additions & 0 deletions tests/test_client_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ def test_host_port(self):
self.assertTrue(req.ssl)
self.loop.run_until_complete(req.close())

def test_websocket_host_port(self):
req = ClientRequest('get', 'ws://python.org/', loop=self.loop)
self.assertEqual(req.host, 'python.org')
self.assertEqual(req.port, 80)
self.assertFalse(req.ssl)
self.loop.run_until_complete(req.close())

req = ClientRequest('get', 'wss://python.org/', loop=self.loop)
self.assertEqual(req.host, 'python.org')
self.assertEqual(req.port, 443)
self.assertTrue(req.ssl)
self.loop.run_until_complete(req.close())

def test_host_port_err(self):
self.assertRaises(
ValueError, ClientRequest, 'get', 'http://python.org:123e/',
Expand Down Expand Up @@ -230,6 +243,12 @@ def test_path_is_not_double_encoded(self):
self.assertEqual(req.path, "/get/test%20case")
self.loop.run_until_complete(req.close())

def test_path_safe_chars_preserved(self):
req = ClientRequest('get', "http://0.0.0.0/get/%:=",
loop=self.loop)
self.assertEqual(req.path, "/get/%:=")
self.loop.run_until_complete(req.close())

def test_params_are_added_before_fragment(self):
req = ClientRequest(
'GET', "http://example.com/path#fragment", params={"a": "b"},
Expand Down