I did some more testing with and without a host configuration in accessing a
different port. It does work either way. I think the last part of the log
message threw me off in stating http:80 (see below). So, now I am back to
thinking it is an authentication problem. Based on the
BasicAuthenticationExample, I assume that all that is required is to set
credentials
client.getState().setCredentials(
null,
new UsernamePasswordCredentials("user", "pwd")
);
and then set
get.setDoAuthentication( true );
The null in setCredentials means set this user/pwd as default.
log...
2003/03/18 19:52:02:200 EST [DEBUG]
HttpConnection - -HttpConnectionManager.getConnection: creating connection
for 127.0.0.1:8080 via null:-1 using protocol: http:80
-----Original Message-----
From: Adrian Sutton [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 7:34 PM
To: 'Commons HttpClient Project'
Subject: RE: download a file
Hi Drake,
It looks like HttpMethodBase is trying to parse retrieve the port from the
URL, but there appears to be a bug in the URI class such that it's not
finding the port. Only Sung-Gu really knows much about that class so if
he's around I'd love to hear from him. :)
Otherwise, we'll have to log this as a bug and take a look at it when
someone is free. I know that the URI classes are moving to their own
commons project soonish, but I think it's time someone needs to learn what
they're on about so we can support them better. If I find time I guess that
will be me. I'm not sure when that will be though so hopefully someone will
beat me to it. :) In the mean time you'll have to create the host
configuration yourself and pass it through.
Adrian Sutton, Software Engineer
Ephox Corporation
www.ephox.com
-----Original Message-----
From: Drake Henderson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 19 March 2003 10:15 AM
To: Commons HttpClient Project
Subject: RE: download a file
Adrian,
The code is below. It is a modification of BasicAuthenticationExample.java.
I've just added the port number to the url of the GetMethod constructor.
Thanks for you help.
HttpClient client = new HttpClient();
// pass our credentials to HttpClient, they will only be used for
// authenticating to servers with realm "realm", to authenticate
agains
// an arbitrary realm change this to null.
client.getState().setCredentials(
null,
new UsernamePasswordCredentials("user", "pwd")
);
// create a GET method that reads a file over HTTPS, we're assuming
// that this file requires basic authentication using the realm
above.
GetMethod get = new
GetMethod("https://www.xyz.com:2082/getsqlbackup/trace.gz");
// Tell the GET method to automatically handle authentication. The
// method will use any appropriate credentials to handle basic
// authentication requests. Setting this value to false will cause
// any request for authentication to return with a status of 401.
// It will then be up to the client to handle the authentication.
get.setDoAuthentication( true );
// execute the GET
int status = client.executeMethod( get );
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]