Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

index.html handling issues #235

Closed
balopat opened this issue Aug 31, 2019 · 0 comments · Fixed by #241
Closed

index.html handling issues #235

balopat opened this issue Aug 31, 2019 · 0 comments · Fixed by #241

Comments

@balopat
Copy link

balopat commented Aug 31, 2019

I would expect index.html handling to work out of the box, but it doesn't seem that way.

package main

import (
	"github.com/gobuffalo/logger"
	"github.com/gobuffalo/packr/v2"
	"github.com/gobuffalo/packr/v2/plog"
	"net/http"
)

func main() {
	plog.Logger = logger.New(logger.DebugLevel)
	box := packr.New("test", "./broken_index")
	http.Handle("/", http.FileServer(box))
	http.ListenAndServe(":3000", nil)
}

under the broken_index directory I have an index.html and an index.htm, and the same under a sub directory: broken_index/sub an index.html and an index.htm.

As http.ServeFile redirects index.html calls to the / and http.serveFile contains the logic to check for existence of index.html under directories if f.IsDir(), I would expect "/", "/index.html", "/sub", "/sub/index.html" to work, but they come back with different errors:
"/" redirects to "http://localhost:3000//" and ends up in too many redirect calls.
"/sub/index.html" returns an empty response:

 curl http://localhost:3000/sub/index.html -v                                                                                 Sat Aug 31 16:44:00 2019
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 3000 (#0)
> GET /sub/index.html HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Location: ./
< Date: Sat, 31 Aug 2019 23:44:12 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

I believe the underlying cause might be related to #211.

The /index.htm and /sub/index.htm urls work (just as a sanity check for my wiring/folder naming).

Lesterpig added a commit to Lesterpig/packr that referenced this issue Sep 30, 2019
The disk resolver was the only one that returned directories as box
files. This modification allows http redirections of index.html to
work when working with the default disk resolver.

A test case has been added to verify http's behavior when working with
the disk resolver.

Fix gobuffalo#162
Fix gobuffalo#211
Fix gobuffalo#235
markbates pushed a commit that referenced this issue Sep 30, 2019
The disk resolver was the only one that returned directories as box
files. This modification allows http redirections of index.html to
work when working with the default disk resolver.

A test case has been added to verify http's behavior when working with
the disk resolver.

Fix #162
Fix #211
Fix #235
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant