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().getMet > 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().getStatusC > ode(), > CoreMatchers.is(200)); > > Assert.assertThat(Arrays.asList(request.getAllHeaders()).toString(), > CoreMatchers.containsString("X-sleep")); > > Assert.assertThat(Arrays.asList(httpRequestFromLocalContext.getAllHea > 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