golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.18k stars 17.57k forks source link

proposal: net/http: add ability to know which requests are HTTP2 push requests #51340

Open mitar opened 2 years ago

mitar commented 2 years ago

When I use http.Pusher interface to push a HTTP request/response, there is no way to know which requests are being pushed, once they become handled. Even more, it seems there is no way for me to tie those requests with the original request in my logging code (e.q., using request ID or something similar).

I would propose that http.PushOptions is extended with additional Context: interface{} field which allows to pass additional information to the pushed request, and that http.Request gets PushContext: interface{} field to read it out. This way I could pass through ID or even some other information which could help handle those requests faster (like internal caches or some other data I already have during handling of the original request).

ianlancetaylor commented 2 years ago

CC @neild @bradfitz