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

Attempted implicit sequence conversion but the response object is in direct passthrough mode. #7

Open
michaelfillier opened this issue Jul 19, 2013 · 7 comments

Comments

@michaelfillier
Copy link

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

@JoePeacock
Copy link

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.

@rbpasker
Copy link

rbpasker commented Mar 4, 2014

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.

@JoePeacock
Copy link

Checkout #10, if you use his fix, it should work ok.

gandaro pushed a commit to gandaro/Flask-gzip that referenced this issue Feb 18, 2015
Use with statement for GzipFile and werkzeug to calculate response length
@joshblum
Copy link

+1 @JoePeacock . @anemitz @philfreo would you guys mind merging #10 and updating the pip package ( #6)

@philfreo
Copy link
Member

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

@joshblum
Copy link

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
#7 (comment)
.

@ohadperry
Copy link

ohadperry commented Jun 17, 2019

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. 

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

No branches or pull requests

6 participants