Ticket #76 (closed defect: fixed)
_serve_default returns a response that can hang the browser
| Reported by: | Dave <https://www.google.com/accounts/o8/id?id=AItOawkWUz0-4-SA0KXnKlsndWkUCLWcg_m_8hc> | Owned by: | sheep |
|---|---|---|---|
| Priority: | High | Milestone: | |
| Component: | Hatta Wiki | Version: | 1.4.1 |
| Keywords: | Cc: |
Description
_serve_default returns a werkzeug.Response instead of a WikiResponse. This means that WikiResponse.make_conditional isn't being called, which means that a content-length header is still being sent for 304 responses of static files. That causes at least one browser (safari 5.0.5) to hang waiting for content. It'll hang until the server's keep-alive timeout is reached, and then the page will load.
The fix is simple: just use WikiResponse instead of werkzeug.Response
Change History
comment:3 Changed 9 months ago by Dave <https://www.google.com/accounts/o8/id?id=AItOawkWUz0-4-SA0KXnKlsndWkUCLWcg_m_8hc>
I have the latest version of werkzeug. Even though line 2733 calls make_conditional, werkzeug's make_conditional doesn't do enough to make a valid response, which, I assume, is why you override it in WikiResponse: http://hg.hatta-wiki.org/hatta/file/990f4ef34207/hatta.py#l1644
The important thing is setting self.response = [] because otherwise werkzeug will calculate the length of the response and set a content-length header, erroneously. (Arguably, this is a bug in werkzeug, but since you've already solved the problem in the case of WikiResponse, it makes sense to use it in the serve_default method)

If look at the code at http://hg.hatta-wiki.org/hatta/file/990f4ef34207/hatta.py#l2733, you will see that it calls make_conditional just fine.