I tried a little test to investigate the directory situation. I created a
foo/ directory in web server's root directory. I go to my browser and enter:
The index of the directory shows up and the URL is refreshed to:
This is pretty close to what I expected. The trailing slash is necessary if
relative links on the page for 'foo' are going to be correct.
Earlier someone speculated that the server sent a 302 Temporary Redirect to
achieve this. Sounded reasonable, so to see that I then went to the Python
f = urllib.open('http://127.0.0.1/foo';)
s = f.read()
Turns out that the resulting string is not a redirect at all, but the
contents of the HTML.
So how does my browser know to put the extra / at the end of "foo"? And for
that matter, why does it change the host name to "localhost"?
Unless read() automatically handles the redirects...