Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ryban opened this issue Sep 16, 2020 · 1 comment · Fixed by #298
Closed

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

ryban opened this issue Sep 16, 2020 · 1 comment · Fixed by #298
Assignees
Labels

Comments

@ryban
Copy link

ryban commented Sep 16, 2020

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.

treq/src/treq/client.py

Lines 171 to 175 in 7a8f45a

if isinstance(v, (bytes, six.text_type)):
h.addRawHeader(k, v)
elif isinstance(v, list):
h.setRawHeaders(k, v)

@twm twm changed the title treq will silently ignore invalid header values treq will silently ignore invalid non-string header values Sep 17, 2020
@twm twm added the bug label Sep 17, 2020
@twm twm self-assigned this Sep 29, 2020
@twm twm closed this as completed in #298 Oct 23, 2020
@twm
Copy link
Contributor

twm commented Oct 23, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants