Issue with StaticMiddleWare
spectre013 opened this issue · comments
Have tried the following
Middleware(web.StaticMiddleware("./static"))
Middleware(web.StaticMiddleware("static"))
Middleware(web.StaticMiddleware("/static"))
If the directory exists I get the error
seeker can't seek
If it doesn't exists the page loads with the exception of the static files I get 404's as I would expect.
Little more investigation on this. If you do not have an index file in the static directory then it try's to send the directory to the http.ServeContent() function which is then not able to seek to the end of the file to get the length so send with the request cause it is a directory. So you get the error "seeker can't seek"
was able to work around this by putting this before the serveContent()
if file == "/" {
next(w, req)
return
}
Ouch!
In our environment, sends an absolutely insane Content-Length
(looks like 2^64?) in the case explained above:
$ curl -i localhost:1234/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 9223372036854775807
Content-Type: text/plain; charset=utf-8
Last-Modified: Tue, 08 Sep 2015 05:54:42 GMT
Date: Tue, 08 Sep 2015 05:55:53 GMT
curl: (18) transfer closed with 9223372036854775807 bytes remaining to read
@spectre013's fix appears to work, at least for the /
path case.
Merged ^