mirror of
https://github.com/python/cpython.git
synced 2025-11-20 02:50:14 +00:00
gh-100474: Fix handling of dirs named index.html in http.server (GH-100475)
If you had a directory called index.html or index.htm within a directory, it would cause http.server to return a 404 Not Found error instead of the directory listing. This came about due to not checking that the index was a regular file. I have also added a test case for this situation. Automerge-Triggered-By: GH:merwok
This commit is contained in:
parent
00afa5066b
commit
46e6a28308
3 changed files with 6 additions and 1 deletions
|
|
@ -489,6 +489,9 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
|||
self.check_status_and_reason(response, HTTPStatus.NOT_FOUND)
|
||||
response = self.request('/' + 'ThisDoesNotExist' + '/')
|
||||
self.check_status_and_reason(response, HTTPStatus.NOT_FOUND)
|
||||
os.makedirs(os.path.join(self.tempdir, 'spam', 'index.html'))
|
||||
response = self.request(self.base_url + '/spam/')
|
||||
self.check_status_and_reason(response, HTTPStatus.OK)
|
||||
|
||||
data = b"Dummy index file\r\n"
|
||||
with open(os.path.join(self.tempdir_name, 'index.html'), 'wb') as f:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue