This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients berker.peksag, demian.brecht, last-ent, martin.panter
Date 2015-02-01.09:08:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1422781702.48.0.67238303097.issue23255@psf.upfronthosting.co.za>
In-reply-to
Content
Here is another addition to the existing test suite to detect the bug with the duplicate 404 Not Found responses. It relies on running the non-Windows, non-root test that says

# chmod() doesn't work as expected on Windows, and filesystem
# permissions are ignored by root on Unix

In other words, you trigger it by requesting an unreadable file or directory.

Thanks for your replies to my comments, I think I am understanding your point of view better now. You want functions to either return a file object, or to mutate the connection and send part of the response, but not both (except for sending an error response):

* get_file() returns a file object only
* redirect() sends response headers only

I am trying find a neater way to avoiding calling apply_headers() when list_directory() has already sent the headers. How do you feel about calling apply_headers() from inside get_file_or_dir() and get_index_file()? Or at least put a big fat warning saying get_file_or_dir() may or may not have already sent the headers, indicated by the type of file returned.

Another option might be to split list_directory() into a get-file stage and an apply-headers stage. But in my experience the headers to send are usually tightly coupled with the content body. In this case both vary depending on the redirect, generated directory, or static file cases.
History
Date User Action Args
2015-02-01 09:08:22martin.pantersetrecipients: + martin.panter, berker.peksag, demian.brecht, last-ent
2015-02-01 09:08:22martin.pantersetmessageid: <1422781702.48.0.67238303097.issue23255@psf.upfronthosting.co.za>
2015-02-01 09:08:22martin.panterlinkissue23255 messages
2015-02-01 09:08:22martin.pantercreate