-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Requests 2.11: check_header_validity failed on header with integer value #3477
Comments
Non-strings for header values was never an accepted way to use Requests, sadly, and while it was allowed in prior versions we have since made changes that disallow it. This is primarily because headers are really string-string mappings, but also because the general approach of calling The TL;DR of this is: yes, this was done on purpose, and no, we don't think it's a bug. |
See also: #865. |
Seems like a breaking change for a dot-release, no? |
And you didn't describe this huge modification in the ChangeLog :( |
This is not a breaking API change — the API is clearly documented as being string-based, throughout the documentation. The fact that you were using it with integers, instead of its intended input, is a bug in your code, not with in this codebase or a change in the API. Adding a note in the changelog about this non-breaking change may be a good idea. |
@clarkbreyman-yammer To be clear, this is a bit of a borderline case. You can see the decision making most recently in #3386 and #3388, but the basic argument is: non-string headers were never intended to work, so the fact that they stopped working is acceptable. In fact, that have previously not worked in the past. @lmazuel You're right that this got missed from the changelog though, and that's 100% my fault: the breakage here was incidental of our tighter verification of header values, and as a result I didn't see it when I was compiling the changelog. I'd welcome a PR that updates the changelog if you'd like to make one. |
And to be clear, all three of us are in agreement on this. The fact that sending an integer there ever worked was purely luck. It used to not work at all and we decided it should never work long ago. We never had anything that enforced that though. |
That being said, adding that as a supported feature is potentially a great idea, and would be a welcome API change in my book (if the implementation was made well). However, the current status of things is likely to remain for the extended future. |
Added a note in the changelog. |
Thanks @kennethreitz. |
Ok, thanks for the clarification. I will update my code accordingly. |
@lmazuel on it! |
@lmazuel done ✨🍰✨ |
@lmazuel p.s. thank you for caring :P |
I fixed my code, everything else is working great. Thanks for your ultra quick response time! |
as of 2.11, requests raises an exception if header values are not `str` or `bytes`. see: https://github.com/kennethreitz/requests/issues/3477
Wait, what? How were you sending headers before? |
Just as the guide on the page -- 2016-09-27 17:51 GMT+08:00 Cory Benfield notifications@github.com:
|
@COLDMOUNT |
Got it, cool! Thanks! :) 2016-09-27 18:23 GMT+08:00 Cory Benfield notifications@github.com:
|
This has seemingly always been documented, and broken in a recent release. Reference: https://github.com/kennethreitz/requests/issues/3477 Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Recent versions of requests no longer accept integer header values. See https://github.com/kennethreitz/requests/issues/3477 Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
See also: https://github.com/kennethreitz/requests/issues/3477 Signed-off-by: Kohei Maeda <mkouhei@palmtb.net>
Recent versions of requests no longer accept integer header values. See https://github.com/kennethreitz/requests/issues/3477 Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
1. Adds test for target-* parameters. 2. Fixes an error that is caused by requests not accepting non-string header parameters psf/requests#3477 Closes-Bug: 1708099 Change-Id: Ia5d1ad5062751c15928cbfd7709665a3ed769603
Since python-requests 2.11 (see psf/requests#3477), integer values in headers are no longer automatically converted to strings, so we need to do it ourselves. This is the same change that was done a couple of lines above for the Content-Length header in commit 28a5590.
Since python-requests 2.11 (see psf/requests#3477), integer values in headers are no longer automatically converted to strings, so we need to do it ourselves. This is the same change that was done a couple of lines above for the Content-Length header in commit 28a5590. Signed-off-by: Quentin Pradet <quentinp@apache.org>
Recent versions of requests no longer accept integer header values. See https://github.com/kennethreitz/requests/issues/3477 Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Hi,
Since requests 2.11, all my calls using requests for my app are broken. After debugging, it seems that this version does not accept header with integer value, like it was before.
2.10:
2.11
We define 'Content-Length' in each request. Anyway, using an integer for an header which is semantically an integer makes sense no?
The text was updated successfully, but these errors were encountered: