Skip to content

Commit 1ba3d8b

Browse files
author
leah.culver
committed
Python: exclude default port numbers form url normalization according to section 9.1.2. Thanks Toby White for the fix.
git-svn-id: https://oauth.googlecode.com/svn/code/python@1042 f7ae4463-c52f-0410-a7dc-93bad6e629e8
1 parent 5f9083e commit 1ba3d8b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

oauth/oauth.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,13 @@ def get_normalized_http_method(self):
200200
def get_normalized_http_url(self):
201201
"""Parses the URL and rebuilds it to be scheme://host/path."""
202202
parts = urlparse.urlparse(self.http_url)
203-
# scheme, netloc, path
204-
url_string = '%s://%s%s' % (parts[0], parts[1], parts[2])
205-
return url_string
203+
scheme, netloc, path = parts[:3]
204+
# Exclude default port numbers.
205+
if scheme == 'http':
206+
netloc = netloc.rstrip(':80')
207+
elif scheme == 'https':
208+
netloc = netloc.rstrip(':443')
209+
return '%s://%s%s' % (scheme, netloc, path)
206210

207211
def sign_request(self, signature_method, consumer, token):
208212
"""Set the signature parameter to the result of build_signature."""

0 commit comments

Comments
 (0)