proxy: send proxy version in user-agent header

This commit is contained in:
Jens Langhammer
2020-11-29 19:01:15 +01:00
parent 902953a2c7
commit 0a2c0464df
5 changed files with 47 additions and 32 deletions

View File

@ -0,0 +1,20 @@
package server
import "net/http"
func SetUserAgent(inner http.RoundTripper, userAgent string) http.RoundTripper {
return &addUGA{
inner: inner,
Agent: userAgent,
}
}
type addUGA struct {
inner http.RoundTripper
Agent string
}
func (ug *addUGA) RoundTrip(r *http.Request) (*http.Response, error) {
r.Header.Set("User-Agent", ug.Agent)
return ug.inner.RoundTrip(r)
}