-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http3: Is there an equivalent of http.Server.ConnContext #3603
Comments
Can you explain what your use case is? I’m not sure I fully understand |
Sure. The use case is to be able to easily pass a user-defined per-connection I see in In net.http this is done by |
That makes sense. Thank you for the explanation!
I'm wondering how that would work. In |
It would make sense to go via |
I too am looking to take advantage of something similar. In my case, I'm trying to hook-in and include |
The stream context is not set by the user, it's set by the stream: https://github.com/lucas-clemente/quic-go/blob/af30cef57c5c20ebcb599200a96d89f7c33c3d50/send_stream.go#L66-L80 |
Yes, it is set by the stream, and what I mean is that is probably the place where a subsequent call to a user-supplied function (if supplied) would be where the user could add to that context. |
That’s the QUIC layer though, not http3. It would be very hard to set a context that deep in the stack. |
I am also going to put a +1 in here. Our use case is using a per-connection context to bind a logger, connection-id, and store other metadata about the actual connection. Without this, there's no way to understand or track multiple requests happening over the same connection, etc. |
I'm not opposed to this, just trying to understand how this would be implemented. Any suggestions would be welcome, as I won't have the bandwidth to work on this myself. Happy to discuss design and review a PR though. |
I'd be happy to take a look, I'm very unfamiliar with any of the codebase here,so would need to dig a bit. |
I have a POC in my local workspace. When I get five minutes I’ll tidy it up and make a PR. |
I submitted #3624 which mainly addresses this issue; @marten-seemann if you are happy with that, I can also submit my expose QUIC connection ID patch which (unless I have got things wrong) provides access to connection ID which can be retrieved and injected by the user-provided function to Server.ConnContext |
Hi, I also face the same issues in QUIC layer. I want bind some information to I am using an external map to store the information for working around this. |
It seems to me that all the use cases mentioned on this thread (except the
Since this is done at the time the In my use case, I also need the connection itself, as explained in #4230 (comment). From a pure API point of view, I would suggest using the same name and behavior of For the
In any case, the |
The context passed to Line 74 in 8cad3d2
I'm not opposed to discussing changing that, but that seems to be an orthogonal issue. I'm leaning towards merging #4230, as it's a simple change, and seems to be exactly what Go itself does: https://github.com/golang/go/blob/6db1102605f227093ea95538f0fe9e46022ad7ea/src/net/http/server.go#L3275-L3281 @omz13, @carljkempe and @mattrobenolt Would you be able to take a look at that PR, if it resolves your problem as well? |
Yup, I haven't tested the implementation, but if this works as advertised, this is what I'm looking for. :) |
I am trying to add http/3 support into an existing application.
For my existing application I hook into
http.Server.ConnContext
so I can insert my ownContext
. I was hoping that I could easily do something similar withhttp3.Server
, but I can't see any equivalent mechanisms. Am I not seeing something obvious, or is this not implemented?The text was updated successfully, but these errors were encountered: