Skip to content
Myr

Fixed issue #3696. Added a test for it as well.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Hussain · committed by Hussain · parent eb39a55 · Browse files · 2 files+8 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−0 removed

  • tests:+5 added−0 removed
  • other:+3 added−0 removed

2 files+8 added−0 removed

modified:requests/models.py+3 added
341 unmodified lines
342 url = url.decode('utf8')343 else:344 url = unicode(url) if is_py2 else str(url)345346 # Remove leading and trailing whitespaces from url347 url = url.strip()348349 # Don't do any URL preparation for non-HTTP schemes like `mailto`,350 # `data` etc to work around exceptions from `url_parse`, which351 # handles RFC 3986 only.352 if ':' in url and not url.lower().startswith('http'):
548 unmodified lines
modified:tests/test_requests.py+5 added
138 unmodified lines
139 request = requests.Request('PUT', 'http://example.com',140 data=u"ööö".encode("utf-8")).prepare()141 assert isinstance(request.body, bytes)142143 def test_whitespaces_are_removed_from_url(self):144 # Test for issue #3696145 request = requests.Request('GET', ' http://example.com ').prepare()146 assert request.url == 'http://example.com/'147148 @pytest.mark.parametrize('scheme', ('http://', 'HTTP://', 'hTTp://', 'HttP://'))149 def test_mixed_case_scheme_acceptable(self, httpbin, scheme):150 s = requests.Session()151 s.proxies = getproxies()
1989 unmodified lines