func computeApproximateRequestSize()

in log/request_size.go [27:56]


func computeApproximateRequestSize(r *http.Request, bodyByteCount int64) int64 {
	var s int64

	// Request Line
	s += int64(len(r.Method) + requestLineSpaceBytes)
	if r.URL != nil {
		s += int64(len(r.URL.String()) + requestLineSpaceBytes)
	}

	s += int64(len(r.Proto) + newLineBytes)

	// Headers
	if r.Host != "" {
		s += int64(hostHeaderExtraBytes + len(r.Host) + newLineBytes)
	}

	for name, values := range r.Header {
		for _, value := range values {
			s += int64(len(name) + headerSeparatorBytes + len(value) + newLineBytes)
		}
	}

	// Include the trailing newline after the request headers.
	s += newLineBytes

	// Body
	s += bodyByteCount

	return s
}