mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
rpc: make http server forward UA and Origin via Context
This commit is contained in:
parent
1b5bcde464
commit
e31efa3716
1 changed files with 6 additions and 0 deletions
|
|
@ -238,6 +238,12 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx = context.WithValue(ctx, "remote", r.RemoteAddr)
|
ctx = context.WithValue(ctx, "remote", r.RemoteAddr)
|
||||||
ctx = context.WithValue(ctx, "scheme", r.Proto)
|
ctx = context.WithValue(ctx, "scheme", r.Proto)
|
||||||
ctx = context.WithValue(ctx, "local", r.Host)
|
ctx = context.WithValue(ctx, "local", r.Host)
|
||||||
|
if ua := r.Header.Get("User-Agent"); ua != "" {
|
||||||
|
ctx = context.WithValue(ctx, "User-Agent", ua)
|
||||||
|
}
|
||||||
|
if origin := r.Header.Get("Origin"); origin != "" {
|
||||||
|
ctx = context.WithValue(ctx, "Origin", origin)
|
||||||
|
}
|
||||||
|
|
||||||
body := io.LimitReader(r.Body, maxRequestContentLength)
|
body := io.LimitReader(r.Body, maxRequestContentLength)
|
||||||
codec := NewJSONCodec(&httpReadWriteNopCloser{body, w})
|
codec := NewJSONCodec(&httpReadWriteNopCloser{body, w})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue