Skip to content
This repository

app_iter close method is not called when you have two WebOb middlewares on HEAD requests #74

Open
thefunny42 opened this Issue September 10, 2012 · 1 comment

2 participants

Sylvain Viollon Sergey Schetinin
Sylvain Viollon

Hello,

There is an issue with the class EmptyResponse of response.py (line 1221).
The first if in the constructor is formulated like this:

        if app_iter and hasattr(app_iter, 'close'):

And should be more likely something like:

        if app_iter is not None and hasattr(app_iter, 'close'):

The bug I encounter is that my main application uses the close method, and I have at least two middlewares using WebOb in my WSGI stack. Now when a HEAD request occurs, WebOb returns this EmptyResponse iterator instead of the one of the application, still mapping the close method of the original iterator to this new one. However it defines as well the __len__ method to return zero. Now if you have two middlewares using WebOb, the first middleware will replace the application iterator with this EmptyResponse, and the second will do the same thing, however the if used to map the close method will fail (because of the __len__ method), and the close method of the application will never be mapped, and called.

This bug is really a blocking point for me, and I would greatly appreciate to have it fixed quickly.

Thank you,

Sergey Schetinin
Collaborator

I understand the issue, but please provide a test case to reproduce this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.