On Fri, Apr 26, 2019 at 3:21 AM Oleg Kalnichevski <[email protected]> wrote:
> On Thu, 2019-04-25 at 18:46 -0400, Gary Gregory wrote: > > Hi Oleg and All: > > > > It's seems clear to me, and correct me if I am wrong, that if I want > > my > > custom async proxy to manipulate an HTTP body/entity, I have to do it > > in > > org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd(List<? > > extends > > Header>), for example here: > > > > > > https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java#L396 > > > > > > My problem is that my current implementation which until now did not > > need > > to manipulate the body has custom behavior in the guts of > > a > > org.apache.hc.core5.http.nio.AsyncServerExchangeHandler.handleRequest > > (HttpRequest, > > EntityDetails, ResponseChannel, HttpContext) where I have a bunch of > > proprietary logic working on requests before passing these on to an > > origin > > server. > > > > BUT, when this handleRequest() is called, the body has not been read > > yet. > > > > So I need to move my logic to streamEnd(). > > > > BUT my custom code requires access to the HttpContext as well as the > > ResponseChannel. > > > > My question is: is it OK to augment (I'll provide the PR) streamEnd() > > to > > take the HttpContext and ResponseChannel as parameters. > > > > Thoughts? > > > > It would result in coupling AsyncDataConsumer with server side specific > ResponseChannel. This sounds conceptually very wrong to me. > > AsyncServerExchangeHandler instances are stateful. They can have > instance variables. Why do not you use instance variables to store > whatever state you need between method invocations? > > > https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java#L238 > > ProxyExchangeState actually already has a reference to ResponseChannel. > I am not sure why you would want to change AsyncDataConsumer API. > Thanks Oleg, I will try to piggy back on the exchange state... Gary > > Oleg > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
