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.

classification
Title: SimpleHTTPServer directory-indexing "bug" fix
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, loewis, solomoriah, titus
Priority: normal Keywords: patch

Created on 2003-10-21 14:49 by solomoriah, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
SimpleHTTPServer.py.patch solomoriah, 2003-10-21 14:49 See body.
Messages (5)
msg44813 - (view) Author: Chris Gonnerman (solomoriah) Date: 2003-10-21 14:49
The SimpleHTTPServer.py module, when presented with a
URL of the form:

      http://some.site.com/directory

should redirect the browser to:

      http://some.site.com/directory/

This is evidently a standard behavior of major
webservers (Apache and IIS at least).  SimpleHTTPServer
does not do this, but fortunately it is simple to
implement (patch attached, naturally).

I am providing a fix for 2.2 but this problem appears
to be in earlier versions, and is also in 2.3.  This
patch appears to work fine for 2.3.

msg44814 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-11-13 15:54
Logged In: YES 
user_id=21627

Why is this a bug? SimpleHTTPServer already returns the
directory content if only the directory name is given, with
or without trailing slash. I believe Apache does that only
as an implementation detail, and it is unfortunate that this
detail is exposed to clients.

So unless you can report a specific problem with the
approach taken by SimpleHTTPServer, I'm tempted to reject
this patch.
msg44815 - (view) Author: Chris Gonnerman (solomoriah) Date: 2003-11-14 05:28
Logged In: YES 
user_id=321948

Oops.  Allow me to clarify.  Directory names without a
trailing slash need to be redirected to the same name with
the trailing slash to avoid breaking relative links from the
page.

I use SimpleHTTPServer to test websites which will be
deployed via Apache.  Relative links on default directory
pages (index.html) are broken using SimpleHTTPServer but
work correctly on Apache.

This is a de facto standard at least (I haven't read the
RFC's but both IE and Mozilla expect this behavior).
msg44816 - (view) Author: Titus Brown (titus) Date: 2004-12-19 08:20
Logged In: YES 
user_id=23486

Clearly a bug, IMO: a reference to a directory name w/o a slash
will return the directory listing, but relative links do not then work.
(Does this need more explication or ???)

Patch works against latest CVS & fixes behavior.  Recommend 
application.
msg44817 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2006-12-22 19:09
Committed to the trunk in rev. 53147 and to 25-maint in rev. 53148.  Thanks for the fix!
History
Date User Action Args
2022-04-11 14:56:00adminsetgithub: 39437
2009-07-01 16:18:59josiahcarlsonlinkissue1314572 superseder
2003-10-21 14:49:46solomoriahcreate