Skip to content
Myr

Removing charset from JSON content type; tightening requirements on .encode()

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

authored by Jesse Shapiro · committed by Jesse Shapiro · parent 386382b · Browse files · 1 file+4 added−2 removed
This commit

State

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

Diff stats

1 file+4 added−2 removed

  • other:+4 added−2 removed

1 file+4 added−2 removed

modified:requests/models.py+4 added-2 removed
421 unmodified lines
422 if not data and json is not None:423 # When urllib3 uses pyOpenSSL, it can only resume large uploads424 # properly if receiving a bytes-like object. In Python 2, json.dumps()425 # returns just that, but Python 3 returns a Unicode string.426 content_type = 'application/json; charset=utf-8'427 body = complexjson.dumps(json).encode('utf-8')426 content_type = 'application/json'427 body = complexjson.dumps(json)428 if not isinstance(body, bytes):429 body = body.encode('utf-8')430431 is_stream = all([432 hasattr(data, '__iter__'),433 not isinstance(data, (basestring, list, tuple, dict))
427 unmodified lines