Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: undocumented ServeFile index.html redirect behavior #9876

Closed
laszlothewiz opened this issue Feb 14, 2015 · 3 comments
Closed

net/http: undocumented ServeFile index.html redirect behavior #9876

laszlothewiz opened this issue Feb 14, 2015 · 3 comments

Comments

@laszlothewiz
Copy link

After an hour of head scratching and cursing and found that there's a strange way how ServeFile handles any path's that end with index.html:

  • Instead of serving the file directly it generates a 301 redirect response to the nearest folder

Example:

http.ServeFile(w,r,"/public/blog/index.html")
this redirects to /public/blog/

This is not mentioned in the documentation and could cause undesirable behavior.

I tried to add the note about it to the documentation but got rejected because apparently Go doesn't use Github's pull request system. So I don't know how to get this into the documentation so that others won't get tripped over it.

I would actually propose that "feature" to be removed because it's based on an arbitrary of considering the trailing slash ("/") to be the equivalent of a reference to "index.html".

@bradfitz
Copy link
Contributor

Docs to contribute a patch for review are at: https://golang.org/doc/contribute.html

We should just document it so we're not changing behavior. IIRC, @rsc likes (and implemented) the current behavior. I don't have much preference either way, except for I prefer things not to change. Documenting it is fine.

@bradfitz bradfitz added this to the Go1.5 milestone Feb 15, 2015
@bradfitz bradfitz changed the title Undocumented Behavior of ServeFile in net/http package net/http: undocumented ServeFile index.html redirect behavior Feb 15, 2015
@laszlothewiz
Copy link
Author

Thank you!

I would like to update the docs but the contribution process is very complex! I'm totally confused after looking at it.

Is there a simple way to submit a change for review?

@adg
Copy link
Contributor

adg commented Feb 16, 2015

That's the process. The document looks a lot more complicated than it is, because we made the instructions very thorough. Try following it through. It should take you around 10 minutes, or less.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants