On Sat, 2018-12-15 at 15:09 +0100, Philippe Mouawad wrote:
> Yes, I should have adjusted it.
> The bug for us is that while we should get the GET method in
> localContext.getAttribute(HttpCoreContext.HTTP_REQUEST) we end up
> with the
> proxy related on which is CONNECT and contains only partial headers.
> 

I am sorry I do not understand what it is exactly you consider to be a
problem. Could you please create a GitHub project containing the test
case with the correct asserts that clearly define your expectations?

Oleg 


> Regards
> 
> On Sat, Dec 15, 2018 at 2:57 PM Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Sat, 2018-12-15 at 14:51 +0100, Philippe Mouawad wrote:
> > > Hello Oleg,
> > > Felix has created a JUnit test that shows our issue:
> > > 
> > >    - We use localhost:8888 as proxy
> > >    - And https://jmeter.apache.org is the target site
> > > 
> > > Note that in JMeter we use the HttpRequest from HttpContext as it
> > > contains
> > > all the headers :
> > > 
> > >    - [Host: jmeter.apache.org:443, User-Agent: Apache-
> > > HttpClient/4.5.6
> > >    (Java/1.8.0_161)]
> > >    - It should also contains X-sleep: 5 but as you will see, it
> > > doesn't
> > > 
> > > 
> > > 
> > >     @Test
> > >     public void checkThatHeadersAreNotHidden() throws Exception {
> > >         TrustStrategy trustStrategy = new TrustAllStrategy();
> > >         SSLContext sslContext = new
> > > SSLContextBuilder().loadTrustMaterial(null,
> > > trustStrategy).build();
> > >         SSLConnectionSocketFactory socketFactory = new
> > > SSLConnectionSocketFactory(sslContext);
> > >         CloseableHttpClient httpclient =
> > > HttpClients.custom().setSSLSocketFactory(socketFactory).build();
> > >         try {
> > > 
> > >             HttpHost target = new HttpHost("jmeter.apache.org",
> > > 443,
> > > "https");
> > >             HttpHost proxy = new HttpHost("localhost", 8888,
> > > "http");
> > > 
> > >             RequestConfig config =
> > > RequestConfig.custom().setProxy(proxy).build();
> > >             HttpGet request = new HttpGet("/");
> > >             request.addHeader("X-sleep", "5");
> > >             request.setConfig(config);
> > > 
> > >             HttpContext localContext = new BasicHttpContext();
> > >             CloseableHttpResponse response =
> > > httpclient.execute(target,
> > > request, localContext);
> > >             final HttpRequest httpRequestFromLocalContext =
> > > (HttpRequest)
> > > localContext
> > >                     .getAttribute(HttpCoreContext.HTTP_REQUEST);
> > >             try {
> > > 
> > > Assert.assertThat(httpRequestFromLocalContext.getRequestLine().ge
> > > tMet
> > > hod(),
> > > CoreMatchers.is("CONNECT"));
> > 
> > This assert does not make sense to me. Why would one expect the
> > method
> > to be CONNECT when clearly GET is being issued?
> > 
> > Oleg
> > 
> > 
> > >                 Assert.assertThat(response.getStatusLine().getSta
> > > tusC
> > > ode(),
> > > CoreMatchers.is(200));
> > > 
> > > Assert.assertThat(Arrays.asList(request.getAllHeaders()).toString
> > > (),
> > >                         CoreMatchers.containsString("X-sleep"));
> > > 
> > > Assert.assertThat(Arrays.asList(httpRequestFromLocalContext.getAl
> > > lHea
> > > ders()).toString(),
> > >                         CoreMatchers.containsString("X-sleep"));
> > >             } finally {
> > >                 response.close();
> > >             }
> > >         } finally {
> > >             httpclient.close();
> > >         }
> > >     }
> > > 
> > > On Sat, Dec 15, 2018 at 2:35 PM Oleg Kalnichevski <
> > > ol...@apache.org>
> > > wrote:
> > > 
> > > > On Sat, 2018-12-15 at 00:40 +0100, Philippe Mouawad wrote:
> > > > > Hello ,
> > > > > As a complement if you read the thread.
> > > > > It appears TestProxy doesn’t enter in Tunnel_target mode
> > > > > while
> > > > > JMeter
> > > > > does
> > > > > which triggers the issue.
> > > > > 
> > > > > How can I make HttpClient enter this mode using TestProxy
> > > > > code
> > > > > (in
> > > > > thread)
> > > > > below so that I can provide a reproducer for issue?
> > > > 
> > > > You need to make sure the route is marked as
> > > > TunnelType.TUNNELLED.
> > > > Secure `https` routes are marked TunnelType.TUNNELLED by
> > > > default.
> > > > 
> > > > Oleg
> > > > 
> > > > 
> > > > > I tried debugging but I don’t understand, it seems it depends
> > > > > on
> > > > > number of
> > > > > Hop in httpRoute, but javadocs is very succinct.
> > > > > 
> > > > > Thanks
> > > > > 
> > > > > On Friday, December 14, 2018, Philippe Mouawad <
> > > > > pmoua...@apache.org>
> > > > > wrote:
> > > > > 
> > > > > > Hello,
> > > > > > We have a bug report at JMeter where request headers are
> > > > > > lost
> > > > > > when
> > > > > > a proxy
> > > > > > is used for a request.
> > > > > > 
> > > > > > You can see thread discussion here:
> > > > > > 
> > > > > > http://mail-archives.apache.org/mod_mbox/jmeter-dev/
> > > > > > 
> > > > 
> > > > 
> > 
> > 
201812.mbox/%3cf1831746-eeb7-c0df-75e2-565cc2c56...@internetallee.de
> > > > > > %3e
> > > > > > 
> > > > > > 
> > > > > > It seems hc4 swaps the request stored in local context
> > > > > > leading
> > > > > > to
> > > > > > the
> > > > > > issue.
> > > > > > 
> > > > > > 
> > > > > > Regards
> > > > > > 
> > > > 
> > > > 
> > > > -------------------------------------------------------------
> > > > ----
> > > > ----
> > > > 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
> > 
> > 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to