better logging
This commit is contained in:
parent
84ad9d8f4a
commit
7e15756a68
3
README
3
README
@ -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
|
||||
|
20
server.go
20
server.go
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user