Skip to content

Commit b850c4f

Browse files
committed
feat(serverHandler): add request host to access log
1 parent befcaf4 commit b850c4f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/serverHandler/log.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ func logRequest(logger *serverLog.Logger, r *http.Request, statusCode int) {
3434

3535
uri := util.EscapeControllingRune(r.RequestURI)
3636

37-
buf := serverLog.NewBuffer(3 + len(r.RemoteAddr) + len(code) + len(r.Method) + unescapedLen + len(uri))
37+
buf := serverLog.NewBuffer(3 + len(r.RemoteAddr) + len(code) + len(r.Method) + len(r.Host) + unescapedLen + len(uri))
3838

3939
buf = append(buf, []byte(r.RemoteAddr)...) // ~ 9-47 bytes, mainly 21 bytes
4040
buf = append(buf, ' ') // 1 byte
4141
buf = append(buf, []byte(code)...) // 3 bytes
4242
buf = append(buf, ' ') // 1 byte
4343
buf = append(buf, []byte(r.Method)...) // ~ 3-4 bytes
4444
buf = append(buf, ' ') // 1 byte
45+
buf = append(buf, []byte(r.Host)...)
4546
if unescapedLen > 0 {
4647
buf = append(buf, unescapedUri...)
4748
buf = append(buf, ' ', '<', '=', '>', ' ') // 5 bytes

0 commit comments

Comments
 (0)