|
|
|
@ -300,6 +300,7 @@ func handleConn(c *tls.Conn) {
|
|
|
|
|
t := time.Now() |
|
|
|
|
var request *url.URL |
|
|
|
|
var logPath string |
|
|
|
|
method := "GET" |
|
|
|
|
status := 0 |
|
|
|
|
size := int64(-1) |
|
|
|
|
protocol := "Gemini" |
|
|
|
@ -309,7 +310,7 @@ func handleConn(c *tls.Conn) {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
entry := logEntry(protocol, request, status, size, time.Since(t)) |
|
|
|
|
entry := logEntry(method, protocol, request, status, size, time.Since(t)) |
|
|
|
|
|
|
|
|
|
if !quiet { |
|
|
|
|
log.Println(string(entry)) |
|
|
|
@ -375,7 +376,7 @@ func handleConn(c *tls.Conn) {
|
|
|
|
|
clientCertKeys = append(clientCertKeys, pubKey) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if strings.HasPrefix(requestData, "GET ") { |
|
|
|
|
if strings.HasPrefix(requestData, "GET ") || strings.HasPrefix(requestData, "HEAD ") { |
|
|
|
|
w := newResponseWriter(c) |
|
|
|
|
defer w.WriteHeader(http.StatusOK) |
|
|
|
|
|
|
|
|
@ -399,6 +400,8 @@ func handleConn(c *tls.Conn) {
|
|
|
|
|
r.URL.Scheme = "https" |
|
|
|
|
r.URL.Host = strings.ToLower(r.Host) |
|
|
|
|
|
|
|
|
|
method = r.Method |
|
|
|
|
|
|
|
|
|
request = r.URL |
|
|
|
|
|
|
|
|
|
status, size, logPath = serveHTTPS(w, r) |
|
|
|
@ -441,7 +444,7 @@ func handleConn(c *tls.Conn) {
|
|
|
|
|
status, size, logPath = handleRequest(c, request, requestData) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func logEntry(protocol string, request *url.URL, status int, size int64, elapsed time.Duration) []byte { |
|
|
|
|
func logEntry(method string, protocol string, request *url.URL, status int, size int64, elapsed time.Duration) []byte { |
|
|
|
|
hostFormatted := "-" |
|
|
|
|
pathFormatted := "-" |
|
|
|
|
sizeFormatted := "-" |
|
|
|
@ -461,7 +464,7 @@ func logEntry(protocol string, request *url.URL, status int, size int64, elapsed
|
|
|
|
|
if size >= 0 { |
|
|
|
|
sizeFormatted = strconv.FormatInt(size, 10) |
|
|
|
|
} |
|
|
|
|
return []byte(fmt.Sprintf(`%s - - - [%s] "GET %s %s" %d %s %.4f`, hostFormatted, time.Now().Format(logTimeFormat), pathFormatted, protocol, status, sizeFormatted, elapsed.Seconds())) |
|
|
|
|
return []byte(fmt.Sprintf(`%s - - - [%s] "%s %s %s" %d %s %.4f`, hostFormatted, time.Now().Format(logTimeFormat), method, pathFormatted, protocol, status, sizeFormatted, elapsed.Seconds())) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func handleListener(l net.Listener) { |
|
|
|
|