hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobias Woerenkaemper <tobias.woerenkaem...@bayer.com>
Subject Request loses authorization header when redirected by proxy
Date Tue, 03 Dec 2013 15:51:51 GMT
Hi Oleg,

I am using httpclient 4.3.1 and configured my http client like this:

    HttpHost tmpProxy = new HttpHost("proxyhost", Integer.parseInt(####));
    AuthScope tmpAuthScope = new AuthScope(tmpProxy);
    BasicCredentialsProvider tmpCredentialsProvider = new BasicCredentialsProvider();
    Credentials tmpCredentials = new UsernamePasswordCredentials("username", "****");
    tmpCredentialsProvider.setCredentials(tmpAuthScope, tmpCredentials);

    RequestConfig tmpRequestConfig = RequestConfig.custom()
      .setConnectTimeout(4000)
      .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC))
      .setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC))
      .build();

    HttpClient tmpClient = HttpClients.custom()
      .setDefaultRequestConfig(tmpRequestConfig)
      .setProxy(tmpProxy)
      .setDefaultCredentialsProvider(tmpCredentialsProvider)
      .setTargetAuthenticationStrategy(new SummonAuthenticationStrategy())
      .build();

Now I am sending an http request with an Authorization/Authentication header since the request
target needs basic authentication as well:

    HttpGet tmpGetRequest = new HttpGet("target url");
    tmpGetRequest.addHeader("Authorization", ".....");

While being routed through the proxy the (2nd) request seems to lose this authentication header
and hence I am getting a 401 by the target server.

Best Regards
Tobias

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message