You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Remis (JIRA)" <ji...@apache.org> on 2013/11/21 16:48:36 UTC
[jira] [Commented] (HTTPCLIENT-1435) Proxy authentication of Fluent
API does not work
[ https://issues.apache.org/jira/browse/HTTPCLIENT-1435?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13829043#comment-13829043 ]
Remis commented on HTTPCLIENT-1435:
-----------------------------------
Thanks for the super fast fix.
I am sorry for the dummy question, but the most recent snapshot JAR that I found is from 11.Oct.2013: https://repository.apache.org/content/repositories/snapshots/org/apache/httpcomponents/fluent-hc/4.3.2-SNAPSHOT
So, where can I get the latest snapshot JAR?
> Proxy authentication of Fluent API does not work
> ------------------------------------------------
>
> Key: HTTPCLIENT-1435
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1435
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: Fluent HC
> Affects Versions: 4.3.1
> Environment: Win7 + JDK6 + HttpClient 4.3.1 + HttpCore 4.3
> Reporter: Remis
> Fix For: 4.3.2
>
>
> The sample code below demonstrates the issue:
> package com.test;
> import org.apache.http.HttpHost;
> import org.apache.http.auth.AuthScope;
> import org.apache.http.auth.UsernamePasswordCredentials;
> import org.apache.http.client.CredentialsProvider;
> import org.apache.http.client.config.RequestConfig;
> import org.apache.http.client.fluent.Executor;
> import org.apache.http.client.fluent.Request;
> import org.apache.http.client.methods.HttpPost;
> import org.apache.http.impl.client.BasicCredentialsProvider;
> import org.apache.http.impl.client.HttpClientBuilder;
> public class Test {
> public static void main(final String[] args) {
> final HttpHost proxy = new HttpHost("my-proxy.com", 8080);
> final String username = "username";
> final String password = "password";
> final String uri = "https://www.my-uri.com/servlet/action";
> // WORKS: HTTP/1.1 200 OK
> final CredentialsProvider credsProvider = new BasicCredentialsProvider();
> credsProvider.setCredentials(new AuthScope(proxy), new UsernamePasswordCredentials(username, password));
> final HttpPost httppost = new HttpPost(uri);
> httppost.setConfig(RequestConfig.custom().setProxy(proxy).build());
> try {
> System.out.println(HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build()
> .execute(httppost).getStatusLine());
> } catch (final Exception e) {
> e.printStackTrace();
> }
> // WORKS: as expected: HTTP/1.1 407 Proxy Authentication Required
> try {
> System.out.println(Request.Post(uri).viaProxy(proxy).execute().returnResponse().getStatusLine());
> } catch (final Exception e) {
> e.printStackTrace();
> }
> // FAILS (not expected): java.net.UnknownHostException:
> try {
> final Executor executor = Executor.newInstance().auth(proxy, username, password).authPreemptive(proxy);
> System.out.println(executor.execute(Request.Post(uri).viaProxy(proxy)).returnResponse().getStatusLine());
> } catch (final Exception e) {
> e.printStackTrace();
> }
> }
> }
> The stacktrace below is what I get:
> HTTP/1.1 200 OK
> HTTP/1.1 407 Proxy Authentication Required
> java.net.UnknownHostException: www.my-uri.com/servlet/action
> at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
> at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:850)
> at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1201)
> at java.net.InetAddress.getAllByName0(InetAddress.java:1154)
> at java.net.InetAddress.getAllByName(InetAddress.java:1084)
> at java.net.InetAddress.getAllByName(InetAddress.java:1020)
> at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:44)
> at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:102)
> at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:314)
> at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:357)
> at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:218)
> at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:194)
> at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:85)
> at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
> at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
> at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
> at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
> at org.apache.http.client.fluent.Executor.execute(Executor.java:215)
> at com.test.Test.main(Test.java:44)
--
This message was sent by Atlassian JIRA
(v6.1#6144)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org