Hi Oleg, How can we force to use a different protocols for different requests using same httpclient object is what I am looking for until now but was unscuccessful in finding any examples or achieving it using async httpclient implementation.
Input request is not in my control. It could be from a HTTP 2 enabled client or from non enabled client as well. My server supports both protocols and now as my application is reverse proxy it should make sure that error is returned if that protocol is not supported by actual server and if supported response should be provided back. This is the reason I was trying to control it with below option but httpclient is itself throwing error. *AsyncRequestBuilder* APIs *setVersion* method by using *HttpVersion.HTTP_2* or *HttpVersion.HTTP_2_0* argument request is failing with *Unsupported version* error for a https url. Regards, Sreenivas On Sat, Nov 19, 2022, 11:37 PM Oleg Kalnichevski <ol...@apache.org> wrote: > On Sat, 2022-11-19 at 23:22 +0530, sreenivas somavarapu wrote: > > Hi Oleg, > > > > Yes if actual server doesn't support the request should fail. As > > conveyed > > earlier I am trying simple reverse proxy application for which > > requirement > > is end to end flow should use same protocol. My application gets > > request > > from users and my application should make sure that same protocol > > should be > > used as in request when getting the response from different servers > > using > > httpclient. So I was checking the feasibility in httpclient classic / > > async > > implementations to see if I could achieve that using same httpclient > > method. > > > > Regards, > > Sreenivas > > > > I am still confused. If you do not want protocol negotiation, just do > not use it. If can force the desired protocol version. > > Oleg > > > > On Sat, Nov 19, 2022, 11:13 PM Oleg Kalnichevski <ol...@apache.org> > > wrote: > > > > > On Sat, 2022-11-19 at 23:10 +0530, sreenivas somavarapu wrote: > > > > Hi Oleg, > > > > > > > > Thank you for your reply. > > > > > > > > My simple use case is I want to control on which channel / > > > > protocol > > > > (HTTP 1.x or HTTP 2) the requests should use using async > > > > httpclient > > > > api implementation irrespective of backend server enablement of > > > > that > > > > respective protocol. > > > > > > This makes no sense. If the opposite endpoint does not support H2 > > > HttpClient will not be able to execute request with that protocol. > > > > > > Oleg > > > > > > > > > > > > > > > > Regards, > > > > Sreenivas > > > > > > > > On Sat, Nov 19, 2022, 3:47 PM Oleg Kalnichevski > > > > <ol...@apache.org> > > > > wrote: > > > > > On Fri, 2022-11-18 at 13:45 +0530, sreenivas somavarapu wrote: > > > > > > Hi Oleg, > > > > > > > > > > > > Thank you for your reply and conformation. > > > > > > > > > > > > I was looking at async APIs on how to achieve both HTTP 1.x > > > > > > and > > > > > > HTTP > > > > > > 2 > > > > > > support using same HttpAsyncClients builder but initial > > > > > > glance at > > > > > > APIs > > > > > > looks like it is not possible. Is my understanding correct? > > > > > > > > > > > > > > > No, it is not. > > > > > > > > > > > > > > > > Below are > > > > > > different types of configurations I have used. Please let me > > > > > > know > > > > > > if > > > > > > you > > > > > > need my complete sample code? For these tests I was using IIS > > > > > > server > > > > > > with > > > > > > HTTP2 enabled and as well as https://hc.apache.org website as > > > > > > well. > > > > > > > > > > > > I am trying with *setVersionPolicy* method on > > > > > > *HttpAsyncClients* > > > > > > API > > > > > > and if > > > > > > use *NEGOTIATE* version policy then it is working fine. If I > > > > > > use > > > > > > any > > > > > > of > > > > > > *FORCE_HTTP_** version policy then I am getting *400 bad > > > > > > request*. > > > > > > > > > > > > If I keep it as *NEGOTIATE* and then try to force HTTP2 > > > > > > request > > > > > > using > > > > > > *AsyncRequestBuilder* APIs setVersion method bu using > > > > > > *HttpVersion.HTTP_2* > > > > > > or *HttpVersion.HTTP_2_0* argument request is failing with > > > > > > *Unsupported > > > > > > version* error. > > > > > > > > > > > > My usecase is I have a small web app which will be used by > > > > > > users > > > > > > to > > > > > > get > > > > > > data from different servers. I am using httpclient here to > > > > > > get > > > > > > data > > > > > > from > > > > > > pre-configured servers which I even don't know before hand. > > > > > > Basically > > > > > > kind > > > > > > of reverse proxy. So if users request the data using HTTP 1.x > > > > > > I > > > > > > have > > > > > > to get > > > > > > data from backend server using HTTP 1.x only and vice-versa > > > > > > as > > > > > > well. > > > > > > > > > > > > Thank you once again for the help you are providing. > > > > > > > > > > > > > > > > I am not sure I understand what your are trying to do here. If > > > > > want > > > > > HttpClient to negotiate the protocol you need to use the > > > > > NEGOTIATE > > > > > protocol policy with HTTPS. One only needs to use FORCE_HTTP_2 > > > > > when > > > > > connecting to an HTTP/2 endpoint over HTTP (so called h2c). > > > > > > > > > > Oleg > > > > > > > > > > > > > > > --------------------------------------------------------------- > > > > > ---- > > > > > -- > > > > > To unsubscribe, e-mail: > > > > > httpclient-users-unsubscr...@hc.apache.org > > > > > For additional commands, e-mail: > > > > > httpclient-users-h...@hc.apache.org > > > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org > For additional commands, e-mail: httpclient-users-h...@hc.apache.org > >