Flask-gzip
Flask-gzip copied to clipboard
Attempted implicit sequence conversion but the response object is in direct passthrough mode.
Is there a way to test this out while using Flask's built-in development server? I tried and I get an error:
"RuntimeError: Attempted implicit sequence conversion but the response object is in direct passthrough mode."
Here is the link of code on werkzeug that throws the error: https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/wrappers.py#L897
You can set response.direct_passthrough = False manually in your after_request function. This will override your error. I had the same problem, and this is just a quick fix.
However, response.data is suggested by Flask to not be used as it is in this plugin, and that it will be deprecated at some point. The only other proper way to fix this is to build your own subclass for the Response class, or edit the current one with process_response(). You can simply override these functions and define them as you wish, giving you complete control of your responses.
I am having this problem as well. my app doesn't use any @werkzeug classes at all, just flask and flask-gzip. perhaps someone from @werkzeug can help.
Checkout https://github.com/elasticsales/Flask-gzip/pull/10, if you use his fix, it should work ok.
+1 @JoePeacock . @anemitz @philfreo would you guys mind merging #10 and updating the pip package ( #6)
We haven't had a chance to maintain this project in a while -- you might want to check out https://github.com/wichitacode/flask-compress in the meantime
Great, thanks!
El viernes, 10 de abril de 2015, Phil Freo [email protected] escribió:
We haven't had a chance to maintain this project in a while -- you might want to check out https://github.com/wichitacode/flask-compress in the meantime
— Reply to this email directly or view it on GitHub https://github.com/elasticsales/Flask-gzip/issues/7#issuecomment-91635827 .
EDIT:
my mistake simply moved to be defined as the last app.after_request
Hi, I have Flask 1.0.2
I've tried
@app.after_request
def after_request(r):
r.direct_passthrough = False
... other after hooks....
return r
and it doesn't work. The code fails before even reaching there.