mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Rename utils.requote_path to requote_uri.
It is now applied to a whole URI, not just the path.
This commit is contained in:
+2
-2
@@ -26,7 +26,7 @@ from .exceptions import (
|
||||
URLRequired, SSLError)
|
||||
from .utils import (
|
||||
get_encoding_from_headers, stream_decode_response_unicode,
|
||||
stream_decompress, guess_filename, requote_path, dict_from_string)
|
||||
stream_decompress, guess_filename, requote_uri, dict_from_string)
|
||||
|
||||
from .compat import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, str, bytes, SimpleCookie, is_py3, is_py2
|
||||
|
||||
@@ -342,7 +342,7 @@ class Request(object):
|
||||
else:
|
||||
url = '%s?%s' % (url, self._enc_params)
|
||||
|
||||
url = requote_path(url)
|
||||
url = requote_uri(url)
|
||||
|
||||
return url
|
||||
|
||||
|
||||
+4
-4
@@ -419,14 +419,14 @@ def unquote_unreserved(uri):
|
||||
parts[i] = '%' + parts[i]
|
||||
return ''.join(parts)
|
||||
|
||||
def requote_path(path):
|
||||
"""Re-quote the given URL path component.
|
||||
def requote_uri(uri):
|
||||
"""Re-quote the given URI.
|
||||
|
||||
This function passes the given path through an unquote/quote cycle to
|
||||
This function passes the given URI through an unquote/quote cycle to
|
||||
ensure that it is fully and consistently quoted.
|
||||
"""
|
||||
# Unquote only the unreserved characters
|
||||
# Then quote only illegal characters (do not quote reserved, unreserved,
|
||||
# or '%')
|
||||
return quote(unquote_unreserved(path), safe="!#$%&'()*+,/:;=?@[]~")
|
||||
return quote(unquote_unreserved(uri), safe="!#$%&'()*+,/:;=?@[]~")
|
||||
return "/".join(parts)
|
||||
|
||||
Reference in New Issue
Block a user