better logging

This commit is contained in:
Steve 2020-02-19 15:56:32 -05:00
parent 84ad9d8f4a
commit 7e15756a68
2 changed files with 11 additions and 12 deletions

3
README
View File

@ -2,7 +2,6 @@ SecretShop: a small Gemini server.
# Features
* Multi-site hosting
* CGI (WIP)
* Fully compliant with Jetforce diagnostics
* Probably won't kill your computer
@ -22,7 +21,7 @@ localhost:
KeyFile: "localhost.key"
CertFile: "localhost.crt"
Please note that CGIDir currently not used (waiting on spec clarification).
# Running
Either run the executable directly or use the SystemD unit file

View File

@ -123,19 +123,19 @@ func (c *conn) serve(ctx context.Context) {
data[count] = b
count = count + 1
}
var res Response
var req string
if !strings.Contains(string(data), "\r\n") {
c.sendResponse(Response{STATUS_BAD_REQUEST, "Request too large", ""})
c.C.Close()
return
res = Response{STATUS_BAD_REQUEST, "Request too large", ""}
req = "TOO_LONG_REQUEST"
} else if !utf8.Valid(data) {
res = Response{STATUS_BAD_REQUEST, "URL contains non UTF8 charcaters", ""}
} else {
req = string(data[:count-2])
res = c.server.ParseRequest(req)
}
if !utf8.Valid(data) {
c.sendResponse(Response{STATUS_BAD_REQUEST, "URL contains non UTF8 charcaters", ""})
c.C.Close()
return
}
req := string(data[:count-2])
res := c.server.ParseRequest(req)
c.sendResponse(res)
log.Printf("%v: %v requested %v; responded with %v %v", c.server.Hostname, c.C.RemoteAddr(), req, res.Status, res.Meta)
c.C.Close()
}