ITADN

[useragent]: Defaults to go-http-client if original request has empty UA

#154OpenLaurenceJJones 创建于 2025-09-25
L
LaurenceJJonescommented
### Welcome! - [x] Yes, I've searched similar issues on [GitHub](https://github.com/traefik/whoami/issues) and didn't find any. ### What did you do? I currently using whoami to see what requests headers are being proxied by Haproxy to ensure our WAF integration works properly. However, I found an odd behavior when testing our empty useragent rules, the request from Haproxy to our WAF is correct but the response from whoami shows: ``` $ curl -A "" http://127.0.0.1:9090/ Hostname: 275a42461af8 IP: 127.0.0.1 IP: ::1 IP: 10.5.5.2 IP: fe80::b48b:e3ff:fe5a:7bef RemoteAddr: 10.5.5.4:52688 GET / HTTP/1.1 Host: 127.0.0.1:9090 User-Agent: Go-http-client/1.1 Accept: */* X-Crowdsec-Remediation: allow X-Unique-Id: 32771e77-2cb0-43c7-83c7-44da150b761a ``` The reason that this happens is within the code whoami writes the request onto the response writer and the request will default to certain values if some headers are not set. ``` if err := r.Write(w); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } ``` ### What were you expecting? I expected whoami to actually respond with the requested headers and attempt to stop golang from imposing it "smart" defaults. ### What version are you using? 1.11.0 ### What is your environment & configuration? ```yaml whoami: image: traefik/whoami:latest networks: - crowdsec command: - --port=2020 ``` Add more configuration information here. ### If applicable, please paste the log output in DEBUG level _No response_
0 条评论