srvdir icon indicating copy to clipboard operation
srvdir copied to clipboard

HEAD request to any srvdir URL returns 405 method not allowed

Open jadedgnome opened this issue 11 years ago • 7 comments

wget --spider https://*******.srvdir.net 2>&1

HTTP request sent, awaiting response... 405 Method Not Allowed Remote file does not exist -- broken link!!!

jadedgnome avatar Jun 16 '14 01:06 jadedgnome

Yeah, srvdir should definitely support the HEAD method, I'll change the title.

inconshreveable avatar Jun 16 '14 05:06 inconshreveable

Is this http://golang.org/pkg/net/http/ what you were referring to?

jadedgnome avatar Aug 09 '14 15:08 jadedgnome

Yes, that's what I'm referring to. I thought I fixed this at one point. Might be in a branch, I'll take a closer look.

inconshreveable avatar Aug 15 '14 08:08 inconshreveable

Any updates? I came across the same error when running wget -m -c <URL>

jadedgnome avatar Dec 15 '14 11:12 jadedgnome

No updates yet, but I'm hoping to get some time to devote to srvdir again soon

inconshreveable avatar Dec 16 '14 18:12 inconshreveable

zenguy_pc asked about this on #go-nuts. So I took a quick look and it appears you need to add a case for HEAD here just a quick look but you need to add a case for head [here]((https://github.com/inconshreveable/srvdir/blob/2538286c228a9bcfacb59d7e31429cfcbbc18297/src/srvdir/client/fs.go#L523) as it is currently use the default case.

@inconshreveable @jadedgnome maybe you can fix this now it should only be a few lines. Let me know if you have any general go related questions.

epelc avatar Jan 05 '15 02:01 epelc

@epelc Thanks for looking into this and sorry for the slow response! You're absolutely right, but I think it's a little more involved than that. In order to properly support the HEAD method, the code will have to do all of the logic to determine whether the file exists and then, if appropriate, set the same headers (like maybe content-length) to match as if it were going to serve the file. I think it shouldn't be too bad to refactor fileHandler.serveFile to do that.

Happy to take a pull request if you have the time for it.

inconshreveable avatar Jan 12 '15 04:01 inconshreveable