Skip to content
Myr

Ensure Content-Length is a string.

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

authored by Cory Benfield · committed by Cory Benfield · parent 16ba63c · Browse files · 2 files+13 added−4 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+13 added−4 removed

  • other:+13 added−4 removed

2 files+13 added−4 removed

modified:requests/models.py+2 added-2 removed
119 unmodified lines
120 if isinstance(fp, str):121 fp = StringIO(fp)122 if isinstance(fp, bytes):123 fp = BytesIO(fp)124 124125 if ft:126 new_v = (fn, fp.read(), ft)127 else:128 new_v = (fn, fp.read())
216 unmodified lines
345 not isinstance(data, dict)346 ])347348 try:349 length = super_len(data)349 length = str(super_len(data))350 except (TypeError, AttributeError):351 length = False352353 if is_stream:
288 unmodified lines
modified:test_requests.py+11 added-2 removed
7 unmodified lines
8import unittest910import requests11from requests.auth import HTTPDigestAuth12from requests.compat import str1314try:15 import StringIO16except ImportError:17 import io as StringIO1819HTTPBIN = os.environ.get('HTTPBIN_URL', 'http://httpbin.org/')2021def httpbin(*suffix):22 """Returns url for HTTPBIN resource."""
113 unmodified lines
136 r = requests.put(httpbin('put'))137 self.assertEqual(r.status_code, 200)138139 def test_BASICAUTH_TUPLE_HTTP_200_OK_GET(self):134135140 auth = ('user', 'pass')141 url = httpbin('basic-auth', 'user', 'pass')142143 r = requests.get(url, auth=auth)
123 unmodified lines
267 'text/py-content-type')})268 self.assertEqual(r.status_code, 200)269 self.assertTrue(b"text/py-content-type" in r.request.body)270271 def test_content_length_is_string_for_file_objects(self):272 r = requests.Request(url='http://httpbin.org/post',273 data=StringIO.StringIO('abc')).prepare()274 self.assertTrue(type(r.headers['Content-Length']) == str)275276277if __name__ == '__main__':278 unittest.main()