You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by pwang <ph...@hotmail.com> on 2012/01/12 17:29:56 UTC

HTTP Async Client Digest Authentication over HTTP 1.0 style connection

Hi,

I'm trying to use the HTTP Async client v4.0 alpha 3 to communicate with a
HTTP v1.0-style server with Basic Digest authentication.  I started with the
basic example "
http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchange.java
Asynchronous HTTP exchange ", and updated the first couple lines to this:

        DefaultHttpAsyncClient httpclient = new DefaultHttpAsyncClient();
        httpclient.getCredentialsProvider().setCredentials(
                new AuthScope("localhost", 8080),
                new UsernamePasswordCredentials("super", "super1"));

The server actually returns in the response HTTP 1.1 but includes
"Connection: close" in the response header.  Right after the response is
done sending, the server closes the connection.  This is a snapshot of
initial transaction:

GET / HTTP/1.1
Host: localhost:8080
Connection: Keep-Alive
User-Agent: Apache-HttpAsyncClient/4.0-alpha3 (java 1.5)

HTTP/1.1 401 Unauthorized
Content-Type: application/json
Connection: close
WWW-Authenticate: Digest realm="@127.0.0.1", qop="auth", nonce="31",
opaque="deadbeef"

When I run the modified example, the future.get() call returns with null,
and the program errors out on a null exception (due to the
response.getStatusLine()).

My question is: Is my modification to the example valid for what I'm trying
to do?  Can one of the guru tell me whether there is a problem with my
example code, or if there is a problem with the http async client library
code?  If there's a problem in the http async client library code, where
might I go digging to fix it?  Thanks!

p.w.
-- 
View this message in context: http://old.nabble.com/HTTP-Async-Client-Digest-Authentication-over-HTTP-1.0-style-connection-tp33128907p33128907.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HTTP Async Client Digest Authentication over HTTP 1.0 style connection

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2012-01-12 at 08:29 -0800, pwang wrote:
> Hi,
> 
> I'm trying to use the HTTP Async client v4.0 alpha 3 to communicate with a
> HTTP v1.0-style server with Basic Digest authentication.  I started with the
> basic example "
> http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchange.java
> Asynchronous HTTP exchange ", and updated the first couple lines to this:
> 
>         DefaultHttpAsyncClient httpclient = new DefaultHttpAsyncClient();
>         httpclient.getCredentialsProvider().setCredentials(
>                 new AuthScope("localhost", 8080),
>                 new UsernamePasswordCredentials("super", "super1"));
> 
> The server actually returns in the response HTTP 1.1 but includes
> "Connection: close" in the response header.  Right after the response is
> done sending, the server closes the connection.  This is a snapshot of
> initial transaction:
> 
> GET / HTTP/1.1
> Host: localhost:8080
> Connection: Keep-Alive
> User-Agent: Apache-HttpAsyncClient/4.0-alpha3 (java 1.5)
> 
> HTTP/1.1 401 Unauthorized
> Content-Type: application/json
> Connection: close
> WWW-Authenticate: Digest realm="@127.0.0.1", qop="auth", nonce="31",
> opaque="deadbeef"
> 
> When I run the modified example, the future.get() call returns with null,
> and the program errors out on a null exception (due to the
> response.getStatusLine()).
> 
> My question is: Is my modification to the example valid for what I'm trying
> to do?  Can one of the guru tell me whether there is a problem with my
> example code, or if there is a problem with the http async client library
> code? 

Your code looks reasonable. Quite likely the problem is caused by a bug
in HttpAsyncClient. Please raise a JIRA for this issue and attach a
complete wire / context log of the HTTP session to it.

Oleg



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