Skip to content

Commit

Permalink
Add more comments to make_franken_uri; #195
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Jun 21, 2013
1 parent 1c5c005 commit 0fa34b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions aspen/http/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,24 @@ def make_franken_uri(path, qs):
"""
if path:
try:
path.decode('ASCII')
path.decode('ASCII') # NB: We throw away this unicode!
except UnicodeDecodeError:

# XXX How would we get non-ASCII here? The lookout.net post
# indicates that all browsers send ASCII for the path.

# Some servers (gevent) clobber %2F inside of paths, such
# that we see /foo%2Fbar/ as /foo/bar/. The %2F is lost to us.
parts = [urllib.quote(x) for x in quoted_slash_re.split(path)]
path = "%2F".join(parts)

if qs:
try:
qs.decode('ASCII')
qs.decode('ASCII') # NB: We throw away this unicode!
except UnicodeDecodeError:
# Cross our fingers and hope we have UTF-8 bytes from MSIE.
# Cross our fingers and hope we have UTF-8 bytes from MSIE. Let's
# perform the percent-encoding that we would expect MSIE to have
# done for us.
qs = urllib.quote_plus(qs)
qs = '?' + qs

Expand Down

0 comments on commit 0fa34b6

Please sign in to comment.