twisted / treq

Python requests like API built on top of Twisted's HTTP client.
Other
587 stars 139 forks source link

treq will silently ignore invalid non-string header values #294

Closed ryban closed 3 years ago

ryban commented 3 years ago

If a header value is something other than a string, bytes, or list, treq will silently drop the header. It should raise an error instead.

For example this request would not send Some-Header:

treq.get('http://example.com', headers={'Some-Header': uuid.uuid4()})

This if statement needs a final else to raise an error.

https://github.com/twisted/treq/blob/7a8f45af471d172254176e4d71c8d2c0cbc5a7ae/src/treq/client.py#L171-L175

twm commented 3 years ago

This will no longer be silent in the next release, as treq will issue a deprecation warning. The release after that, #302 calls for a TypeError.