Martin Panter added the comment:

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.

----------
Added file: http://bugs.python.org/file37955/index-test.2.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23255>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to