diff options
| author | adnano <[email protected]> | 2020-09-29 10:13:57 -0400 |
|---|---|---|
| committer | adnano <[email protected]> | 2020-09-29 10:13:57 -0400 |
| commit | d7f515c0cb2f8511c39f2df2ea5120ed290d5134 (patch) | |
| tree | 78acb80143ec80823dddf85a7a66e9c4cb40ab42 /server.go | |
| parent | Use path instead of filepath (diff) | |
| download | go-gemini-d7f515c0cb2f8511c39f2df2ea5120ed290d5134.tar.xz go-gemini-d7f515c0cb2f8511c39f2df2ea5120ed290d5134.zip | |
Implement parsing of Gemini text responses
Diffstat (limited to 'server.go')
| -rw-r--r-- | server.go | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -384,11 +384,12 @@ type File interface { type Dir string func (d Dir) Open(name string) (File, error) { - path := path.Join(string(d), name) - f, err := os.OpenFile(path, os.O_RDONLY, 0644) + p := path.Join(string(d), name) + f, err := os.OpenFile(p, os.O_RDONLY, 0644) if err != nil { return nil, err } + if stat, err := f.Stat(); err == nil { if !stat.Mode().IsRegular() { return nil, ErrNotAFile @@ -569,8 +570,6 @@ func (mux *ServeMux) shouldRedirectRLocked(host, path string) bool { // to the canonical path. If the host contains a port, it is ignored // when matching handlers. // -// The path and host are used unchanged for CONNECT requests. -// // Handler also returns the registered pattern that matches the // request or, in the case of internally-generated redirects, // the pattern that will match after following the redirect. @@ -605,7 +604,7 @@ func (mux *ServeMux) Handler(r *Request) (h Handler, pattern string) { } // handler is the main implementation of Handler. -// The path is known to be in canonical form, except for CONNECT methods. +// The path is known to be in canonical form. func (mux *ServeMux) handler(host, path string) (h Handler, pattern string) { mux.mu.RLock() defer mux.mu.RUnlock() |