Skip to content
Myr

Merge pull request #3697 from hussaintamboli/master

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

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

authored by Cory Benfield · committed by GitHub · parents eb39a55, be8b13e · Browse files · 3 files+9 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

3 files+9 added−0 removed

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

3 files+9 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 whitespaces from url347 url = url.lstrip()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
modified:AUTHORS.rst+1 added
170 unmodified lines
171- Michael Hunsinger172- Brian Bamsch <bbamsch32@gmail.com> (`@bbamsch <https://github.com/bbamsch>`_)173- Om Prakash Kumar <omprakash070@gmail.com> (`@iamprakashom <https://github.com/iamprakashom>`_)174- Philipp Konrad <gardiac2002@gmail.com> (`@gardiac2002 <https://github.com/gardiac2002>`_)175- Hussain Tamboli <hussaintamboli18@gmail.com> (`@hussaintamboli <https://github.com/hussaintamboli>`_)