-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
werkzeug request.query_string is of type str
rather than bytes
#38
Comments
That's quite interesting! I see that it behaves differently depending on if there's a query string or not. $ curl "localhost/?qwer=34"
request.query_string is of type <class 'bytes'>
$ curl localhost
request.query_string is of type <class 'str'> I tested it here and I was able to confirm that the development Flask server ( And Gunicorn alone also always returns I also confirmed with my other image I think it's specifically a Meinheld issue. I tested with Meinheld alone, with: from flask import Flask
from flask import request
app = Flask(__name__)
@app.route("/")
def hello():
msg = " request.query_string is of type {}\n".format(type(request.query_string))
return msg
if __name__ == "__main__":
from meinheld import server
server.listen(("0.0.0.0", 80))
server.run(app) And running that directly as a Python script, it shows the strange behavior. Given that, it's not really an issue with this image per se, but with Meinheld, you might want to report it there: https://github.com/mopemope/meinheld |
Thanks for looking into this @tiangolo - I've opened mopemope/meinheld#119 |
Thanks for reporting it there @ltalirz! 🚀 In that case, I think we can close this one, right?
|
Sure, keeping the other issue open is good enough |
When using the flask
request
object (which comes from thewerkzeug
library), I find that using thetiangolo/meinheld-gunicorn-flask:python3.8
docker image therequest.query_string
attribute is of typestr
, while thewerkzeug
documentation clearly states that it should be of typebytes
:This resulted in issues in migrating an existing application to the
tiangolo/meinheld-gunicorn-flask:python3.8
docker image, since it tried to decoderequest.query_string
(str
objects have no.decode
method).I suspect this comes somehow from the combination with
meinheld
, but I open the issue here since this makes it easy to reproduce:Minimum working example
Dockerfile
main.py
The text was updated successfully, but these errors were encountered: