-
Notifications
You must be signed in to change notification settings - Fork 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
Exception 'LookupError: unknown encoding:' when response contains content-type
not handled by requests.utils.get_encoding_from_headers
#2482
Comments
Apparently |
I will provide a PR when I find the time. The proper solution would be of course to also handle properly the possible response headers in |
PR created: #2484 |
Another PR which uses detection instead of default Choose the one you prefer. |
Fixed |
Hi, When the content-type returned in the response is application/octet-stream I am getting the following stacktrace
Since we are checking resp.text is None it is failing the request. Should we do resp.Content check as well if resp.text is None since text encoding couldn't be detected? |
Are you really on latest version? |
Yes. |
Ah, my line numbers weren't matching yours because there had been a few more changes to the file after the release. |
I'll change it to check .content instead. |
or... will that help? .content isnt None in your case, is it? PR welcome :) |
Yeah it isn't none. I'll be happy to raise a PR. |
Raised a PR - #2512, Please review and let me know. |
Prerequisites
Description
When the tested HTTP server returns a Response header of
content-type
that is not handled by the external library method requests.utils.get_encoding_from_headers properly (for examplecontent-type: application/problem+json
) the calling code sets encoding to empty string which results in a bytes to string encoding error here. The thrown exception stack trace:Command line
locust --web-host 127.0.0.1 --web-port 9999 -f locustfile.py
Locustfile contents
Python version
3.9.2
Locust version
2.19.0
Operating system
Debian 11
The text was updated successfully, but these errors were encountered: