Demian Brecht added the comment:

@Serhiy:
> Content-Length shouldn't be calculated for lists, tuples, and other 
> non-bytes-compatible sequences.

I'd agree with this if it wasn't relatively trivial to calculate. There's no 
reason that I can think of to exclude the auto-generated Content-Length header 
for data types for which the size is known.


@Martin:
> Technically I don’t think there is a bug.

The bug is that the Content-Length header is currently added for bodies that 
are lists and tuples and the value is incorrect. For example:

con.request('POST', '/', ['aaa', 'bbb', 'ccc'])

results in 

Host: example.com
Accept-Encoding: identity
Content-Length: 3


@David:
> Since the latter cannot be done reliably unless we know the list or tuple is 
> all bytes, I propose that we don't do it at all (since I'd like to see 
> iterables of text strings supported).

The patch here adds support for iterables of text strings (as well as iterables 
comprised of both bytes and strings). Content-Length can be computed reliably 
as the size of a latin1-encoded string will be identical to the original string.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23350>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to