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
Ability to associate attributes with HttpMessages/HttpObjects #4060
Comments
@rkapsi - We love pull requests :) Although if you plan on adding new interfaces to existing interfaces I think this would have to be targeted at 4.1+. |
@rkapsi @Scottmitch honestly I think this should be not part of the Http* pojos in the core. If you really want to do this you can just write your own implementation of the interface and do it there. |
That's a lot to implement though. It'd probably end up being a bunch of wrapper classes that delegate to pojos that HttpObjectDecoder created. I get cold shivers from that. One thing I've been thinking is if HttpHeaders wouldn't call toString() on header values. It'd be quite elegant and natural for passing values around. |
... But that would be hacky. I'm personally leaning towards something analogous to |
@Scottmitch @normanmaurer I'm happy to iterate on it. We use Netty with non-aggregated HttpMessages and with many ChannelHandlers. One thing that is consistently missing is the ability to share information on a per-request level. |
@normanmaurer - I think the difficulty with creating your own implementation of the interfaces is the codec will not use these objects and as @rkapsi said you must wrap everywhere. Seems like a common problem to have to associate user data with requests/responses? For example in HTTP/2 we have a per stream map where users can store objects. I see value in this but I don't fully understand @normanmaurer's hesitation... @rkapsi - maybe wait to invest effort implementing this until @normanmaurer expands on his concerns a bit more (FYI he is currently on vacation). |
@Scottmitch @normanmaurer so what are your thoughts about this? The wrapping is my least favorite option. It's inefficient and would lead to an awkward parallel type system. One idea could be to change |
Nah, that's not going to work very well with |
@rkapsi @Scottmitch the concern I have with adding the possibility to expose something like an attribute map in the "pojos" is that this has not much to do with the protocol itself. IMHO the pojos that represent the messages should be very light-weight and not carry any extra stuff that is not part of the protocol itself. @trustin WDYT? |
I'd argue "request scopes" and "session scopes" are higher level aspects of the HTTP protocol and my primary (only) motivation for this. Right now there's only "connection scope" ( In my case, the downstream "client" is a Proxy/Load Balancer that uses connection pooling. The This is just one little and arguably lightweight example but there are things that need to be pulled out of a DB and it's very favorable to cache them in the context of the request as it's passing through the pipeline. Here's an another idea. A new interface that
|
|
@trustin The challenge is that a request's scope spans from As for the |
…n the HttpObjectDecoder and create() methods in the HttpObjectAggregator. netty#4060 Motivation: This change allows us to implement higher level HTTP features such as "request scopes" or "session scopes" by being able to customize the HttpMessage and share state that spans HttpMessage over HttpContent to LastHttpContent. Modifications: The HttpObjectDecoder was changed to use explcit create() methods for HttpContent and LastHttpContent objects. The HttpObjectAggregator was changed to expose its internal "aggregated" message types and two create() methods were added. Result: It's now possible to customize the message types that HttpObjectDecoder return and possibly share state that spans from HttpMessage, over HttpContent to LastHttpContent and effectivly implement higher level HTTP abstractions such as "request scopes" or "session scopes".
…n the HttpObjectDecoder and create() methods in the HttpObjectAggregator. netty#4060 Motivation: This change allows us to implement higher level HTTP features such as "request scopes" or "session scopes" by being able to customize the HttpMessage and share state that spans HttpMessage o ver HttpContent to LastHttpContent. Modifications: The HttpObjectDecoder was changed to use explcit create() methods for HttpContent and LastHttpContent objects. The HttpObjectAggregator was changed to expose its internal "aggregated" messag e types and two create() methods were added. Result: It's now possible to customize the message types that HttpObjectDecoder return and possibly share state that spans from HttpMessage, over HttpContent to LastHttpContent and effectivly implem ent higher level HTTP abstractions such as "request scopes" or "session scopes".
Looks like related PR is closed, so that can be also closed by now. |
It'd be great if it was possible to associate attributes with HttpMessages (possibly HttpObjects). and effectively make it very easy to implement things such as HTTP request scopes.
I'm currently using a ChannelHandler that creates + fires a "context" user event object for each newly read HttpMessage but that approach has some maintainability problems.
The text was updated successfully, but these errors were encountered: