Francois,
If the target URL is absolute (explicitly defines a protocol and a
host), it always overrides the default host config. One should be using
relative URLs when expecting the host config to take effect.
I hope this explains it
Oleg
On Wed, 2005-01-26 at 19:23 +0100, Francois Grandjean wrote:
> Hi,
>
> I had exactly the same problem. The proposed solution works but I'm
> still surprised that the following code (setting the configuration also
> on the client level) leads to the same problem:
>
>
> HostConfiguration hostconfig = new HostConfiguration("somehost", 15555,
> MySslProtocolObject);
> HttpClient httpclient = new HttpClient();
> Httpclient. setHostConfiguration(hostconfig) //ADDED LINE
> httpclient.executeMethod(hostconfig, httpget);
>
>
> I looked at the code, and I think the problem comes from lines 382-386:
>
> HostConfiguration defaulthostconfig = getHostConfiguration();
> if (hostConfiguration == null || hostConfiguration == defaulthostconfig)
> {
> // make a deep copy of the host defaults
> hostConfiguration = new HostConfiguration(defaulthostconfig);
> URI uri = method.getURI();
> if (uri.isAbsoluteURI()) {
> hostConfiguration.setHost(uri);
> }
> }
>
> Having the configuration set at the client level makes it enter the if
> statement and clone the config.
> But the call to
> hostConfiguration.setHost(uri);
> overwrites the hostConfiguration.protocol with the default protocol
> registered (Protocol.getProtocol(uri.getScheme())).
>
> Thanks for your feedback.
>
> Francois
>
>
> -----Original Message-----
> From: Riad Souissi [mailto:[EMAIL PROTECTED]
> Sent: lundi 17 janvier 2005 13:20
> To: HttpClient User Discussion
> Subject: RE: Problem with PostMethod.getHostConfiguration().setHost() on
> v3 beta1
>
>
> Thanks, works exactly as expected!
>
> Regards,
> riad
>
>
> -----Original Message-----
> From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED]
>
> Sent: Monday, January 17, 2005 2:13 PM
> To: [email protected]
> Subject: Re: Problem with PostMethod.getHostConfiguration().setHost() on
> v3 beta1
>
> On Mon, Jan 17, 2005 at 01:14:34PM +0300, Riad Souissi wrote:
> >
>
> >
>
> >
>
> > Hi,
> >
>
> > Before, using version 2 or version3_alpha2, the following code was
> > working:
> >
>
> > ----
> > myPostMethod.getHostConfiguration().setHost("somehost", "15555",
> > mySslProtocolObject)
> > ----
> >
>
> > The reason I was setting mySslProtocolObject on the method level is
>
> > because I do not want to force it on the whole host:port. I need to
>
> > have a granular control.
> >
>
> > Then I switched to version3_beta1, and it stopped to work. It does not
>
> > seem to use any of the SSL classes defined within mySslProtocolObject
>
> > (the object which I derived from ProtocolSocketFactory). I used
>
> > println calls to find out that sslProtocolObject was not used when I
>
> > was sending an HTTPS request to host:port using the myPostMethod
> defined above.
> >
>
> > Do you have an idea how to get it back to work ? I know that
> > getHostConfiguration().setHost() is deprecated, but I found no other
>
> > way to do the same thing with this granularity (at the PostMethod
> level).
> >
>
> Hi Riad,
>
> Try this
>
> HostConfiguration hostconfig = new HostConfiguration("somehost", 15555,
> MySslProtocolObject);
> HttpClient httpclient = new HttpClient(); ...
>
> httpclient.executeMethod(hostconfig, httpget);
>
>
> Hope this helps
>
> Oleg
>
> > Regards,
> > riad
> >
>
> > DiscalimerThe information in this email and in any files transmitted
>
> > with it, is intended only for the addressee and may contain
> confidential and/or privileged material.
> > Access to this email by anyone else is unauthorized. If you receive
>
> > this in error, please contact the sender immediately and delete the
> material from any computer.
> > If you are not the intended recipient, any disclosure, copying,
>
> > distribution or any action taken or omitted to be taken in reliance on
> it, is strictly prohibited.
> > Statement and opinions expressed in this e-mail are those of the
>
> > sender, and do not necessarily reflect those of STC.
> >
>
> > ---------------------------------------------------------------------
> > 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]
>
>
> DiscalimerThe information in this email and in any files transmitted
> with it,
> is intended only for the addressee and may contain confidential and/or
> privileged material.
> Access to this email by anyone else is unauthorized. If you receive this
> in error,
> please contact the sender immediately and delete the material from any
> computer.
> If you are not the intended recipient, any disclosure, copying,
> distribution or
> any action taken or omitted to be taken in reliance on it, is strictly
> prohibited.
> Statement and opinions expressed in this e-mail are those of the sender,
> and do not
> necessarily reflect those of STC.
>
>
> ---------------------------------------------------------------------
> 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]