diff --git a/README b/README index e0a6de1..78d90cd 100644 --- a/README +++ b/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 diff --git a/server.go b/server.go index 6e03613..f97cc87 100644 --- a/server.go +++ b/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() }