mirror of https://github.com/k3s-io/k3s
Merge pull request #65752 from hzxuzhonghu/req-ua
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. make use of request.UserAgent() **What this PR does / why we need it**: **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: /assign @sttts **Release note**: ```release-note NONE ```pull/8/head
commit
97a4da713b
|
@ -179,10 +179,8 @@ func FormatURL(scheme string, host string, port int, path string) *url.URL {
|
|||
}
|
||||
|
||||
func GetHTTPClient(req *http.Request) string {
|
||||
if userAgent, ok := req.Header["User-Agent"]; ok {
|
||||
if len(userAgent) > 0 {
|
||||
return userAgent[0]
|
||||
}
|
||||
if ua := req.UserAgent(); len(ua) != 0 {
|
||||
return ua
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
|
|
@ -145,9 +145,9 @@ func (rl *respLogger) Log() {
|
|||
latency := time.Since(rl.startTime)
|
||||
if glog.V(3) {
|
||||
if !rl.hijacked {
|
||||
glog.InfoDepth(1, fmt.Sprintf("%s %s: (%v) %v%v%v [%s %s]", rl.req.Method, rl.req.RequestURI, latency, rl.status, rl.statusStack, rl.addedInfo, rl.req.Header["User-Agent"], rl.req.RemoteAddr))
|
||||
glog.InfoDepth(1, fmt.Sprintf("%s %s: (%v) %v%v%v [%s %s]", rl.req.Method, rl.req.RequestURI, latency, rl.status, rl.statusStack, rl.addedInfo, rl.req.UserAgent(), rl.req.RemoteAddr))
|
||||
} else {
|
||||
glog.InfoDepth(1, fmt.Sprintf("%s %s: (%v) hijacked [%s %s]", rl.req.Method, rl.req.RequestURI, latency, rl.req.Header["User-Agent"], rl.req.RemoteAddr))
|
||||
glog.InfoDepth(1, fmt.Sprintf("%s %s: (%v) hijacked [%s %s]", rl.req.Method, rl.req.RequestURI, latency, rl.req.UserAgent(), rl.req.RemoteAddr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue