mirror of
https://code.rocketnine.space/tslocum/twins.git
synced 2024-11-27 11:28:14 +01:00
Send correct status code when a file is not found
This commit is contained in:
parent
74fa3d5c2e
commit
3cb855acfa
1 changed files with 6 additions and 5 deletions
11
server.go
11
server.go
|
@ -146,7 +146,7 @@ func servePath(c *tls.Conn, request *url.URL, serve *pathConfig) (int, int64) {
|
|||
if !serve.HiddenFiles {
|
||||
for _, piece := range requestSplit {
|
||||
if len(piece) > 0 && piece[0] == '.' {
|
||||
return writeStatus(c, statusTemporaryFailure), -1
|
||||
return writeStatus(c, statusNotFound), -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,9 @@ func servePath(c *tls.Conn, request *url.URL, serve *pathConfig) (int, int64) {
|
|||
if !serve.SymLinks {
|
||||
for i := range requestSplit[pathSlashes:] {
|
||||
info, err := os.Lstat(path.Join(root, strings.Join(requestSplit[pathSlashes:pathSlashes+i+1], "/")))
|
||||
if err != nil || info.Mode()&os.ModeSymlink == os.ModeSymlink {
|
||||
if err != nil {
|
||||
return writeStatus(c, statusNotFound), -1
|
||||
} else if info.Mode()&os.ModeSymlink == os.ModeSymlink {
|
||||
return writeStatus(c, statusTemporaryFailure), -1
|
||||
}
|
||||
}
|
||||
|
@ -263,11 +265,10 @@ func handleRequest(c *tls.Conn, request *url.URL, requestData string) (int, int6
|
|||
|
||||
requireInput := serve.Input != "" || serve.SensitiveInput != ""
|
||||
if request.RawQuery == "" && requireInput {
|
||||
if serve.Input != "" {
|
||||
return writeHeader(c, statusInput, serve.Input), -1, ""
|
||||
} else if serve.SensitiveInput != "" {
|
||||
if serve.SensitiveInput != "" {
|
||||
return writeHeader(c, statusSensitiveInput, serve.SensitiveInput), -1, ""
|
||||
}
|
||||
return writeHeader(c, statusInput, serve.Input), -1, ""
|
||||
}
|
||||
|
||||
if matchedRegexp || matchedPrefix {
|
||||
|
|
Loading…
Reference in a new issue