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 Oleg Kalnichevski <ol...@apache.org> on 2004/11/24 09:40:57 UTC
Re: HttpClient redirect to https locationy
Yi,
HttpClient 2.0.x can't handle cross-site redirects automatically (this
limitation has already been fixed in HttpClient 3.0). However I can't
see how this can be related to the problem you have been having, since
you have explicitly disabled automatic redirects in your code.
I may be of more help if you post the wire/context log of the HTTP
session
http://jakarta.apache.org/commons/httpclient/logging.html
Oleg
On Tue, Nov 23, 2004 at 04:09:44PM -0800, Yi Wang wrote:
> Looks like the trick is here:
>
> [WARN] HttpMethodBase - -Redirect from protocol http to https is not
> supported.
>
>
> ----- Original Message -----
> From: "Yi Wang" <yi...@cisco.com>
> To: <ht...@jakarta.apache.org>
> Sent: Monday, November 22, 2004 5:55 PM
> Subject: HttpClient redirect to https location
>
>
> Hi
> I have a problem using the httpclient redirect features:
> getMethod.setFollowRedirects(false);
> status = httpClient.executeMethod(getMethod);
> locationHeader = getMethod.getResponseHeader("location");
> urlResult = locationHeader.getValue();
> if (urlResult == null)
> System.out.println("urlString is null");
> else
> System.out.println("urlResult is " + urlResult);
> I always get a string :
> http://hostname:1741/nm/servlet/servlet.CsAuthServlet?cmd=loginSuccess&id=79
> DD6F6A83B89CA36CEC1BFB74845371&page=main?command=initializeAndValidate&url=/
> cwhp/cwhp.applications.do&context=/cwhp&port=443
>
> But when using icesoft httpclient package I got the following:
>
> https://hostname:443/nm/servlet/servlet.CsAuthServlet?cmd=loginSuccess&id=79
> DD6F6A83B89CA36CEC1BFB74845371&page=main?command=initializeAndValidate&url=/
> cwhp/cwhp.applications.do&context=/cwhp&port=443
>
> As you can see, only the protocol name and port number are different. And
> the second string is correct.
>
> Here is the code using icesoft:
>
> ice.net.HttpURLConnection.setFollowRedirects(false);
> ice.net.HttpURLConnection uc =
> (ice.net.HttpURLConnection)url.openConnection();
> uc.getContent();
> status = uc.getResponseCode();
>
> //check if we get authenticated or get returned to the authFail page
> urlResult = uc.getHeaderField("Location");
> ice.net.HttpURLConnection.setFollowRedirects(true);
>
> The second output was correct - can someone tell me how I should use the
> httpclient package to generate the right output?
>
> Thanks
>
> Yi
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: HttpClient redirect to https locationy
Posted by Oleg Kalnichevski <ol...@apache.org>.
Yi,
HttpClient 3.0 just recently went beta-1 and all the following releases
will be binary compatible with the existing API.
We do recommend to seriously consider using HttpClient 3.0 for all new
applications, as it sports a significantly better architecture compared
to 2.0 branch, and it has been quite stable even in alpha quality.
Oleg
On Wed, 2004-11-24 at 11:53 -0800, Yi Wang wrote:
> Oleg:
> Thanks.
> I have found that the problem was with the second redirect request. The code
> I posted turned off the aut-redirect in the first try but turned it back on
> in the second try. I fixed it by adding code to handle the redirect
> manually.
> By the way, I didn't use 3.0 because I saw it was still in alpha testing.
> Would you recommend it? I don't know how stable it is now.
>
> Thanks again and Happy thanksgiving!
> Yi
>
> ----- Original Message -----
> From: "Oleg Kalnichevski" <ol...@apache.org>
> To: "HttpClient User Discussion" <ht...@jakarta.apache.org>
> Sent: Wednesday, November 24, 2004 12:40 AM
> Subject: Re: HttpClient redirect to https locationy
>
>
> > Yi,
> >
> > HttpClient 2.0.x can't handle cross-site redirects automatically (this
> > limitation has already been fixed in HttpClient 3.0). However I can't
> > see how this can be related to the problem you have been having, since
> > you have explicitly disabled automatic redirects in your code.
> >
> > I may be of more help if you post the wire/context log of the HTTP
> > session
> >
> > http://jakarta.apache.org/commons/httpclient/logging.html
> >
> > Oleg
> >
> > On Tue, Nov 23, 2004 at 04:09:44PM -0800, Yi Wang wrote:
> > > Looks like the trick is here:
> > >
> > > [WARN] HttpMethodBase - -Redirect from protocol http to https is not
> > > supported.
> > >
> > >
> > > ----- Original Message -----
> > > From: "Yi Wang" <yi...@cisco.com>
> > > To: <ht...@jakarta.apache.org>
> > > Sent: Monday, November 22, 2004 5:55 PM
> > > Subject: HttpClient redirect to https location
> > >
> > >
> > > Hi
> > > I have a problem using the httpclient redirect features:
> > > getMethod.setFollowRedirects(false);
> > > status = httpClient.executeMethod(getMethod);
> > > locationHeader = getMethod.getResponseHeader("location");
> > > urlResult = locationHeader.getValue();
> > > if (urlResult == null)
> > > System.out.println("urlString is null");
> > > else
> > > System.out.println("urlResult is " + urlResult);
> > > I always get a string :
> > >
> http://hostname:1741/nm/servlet/servlet.CsAuthServlet?cmd=loginSuccess&id=79
> > >
> DD6F6A83B89CA36CEC1BFB74845371&page=main?command=initializeAndValidate&url=/
> > > cwhp/cwhp.applications.do&context=/cwhp&port=443
> > >
> > > But when using icesoft httpclient package I got the following:
> > >
> > >
> https://hostname:443/nm/servlet/servlet.CsAuthServlet?cmd=loginSuccess&id=79
> > >
> DD6F6A83B89CA36CEC1BFB74845371&page=main?command=initializeAndValidate&url=/
> > > cwhp/cwhp.applications.do&context=/cwhp&port=443
> > >
> > > As you can see, only the protocol name and port number are different.
> And
> > > the second string is correct.
> > >
> > > Here is the code using icesoft:
> > >
> > > ice.net.HttpURLConnection.setFollowRedirects(false);
> > > ice.net.HttpURLConnection uc =
> > > (ice.net.HttpURLConnection)url.openConnection();
> > > uc.getContent();
> > > status = uc.getResponseCode();
> > >
> > > //check if we get authenticated or get returned to the authFail
> page
> > > urlResult = uc.getHeaderField("Location");
> > > ice.net.HttpURLConnection.setFollowRedirects(true);
> > >
> > > The second output was correct - can someone tell me how I should use the
> > > httpclient package to generate the right output?
> > >
> > > Thanks
> > >
> > > Yi
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: HttpClient redirect to https locationy
Posted by Yi Wang <yi...@cisco.com>.
Oleg:
Thanks.
I have found that the problem was with the second redirect request. The code
I posted turned off the aut-redirect in the first try but turned it back on
in the second try. I fixed it by adding code to handle the redirect
manually.
By the way, I didn't use 3.0 because I saw it was still in alpha testing.
Would you recommend it? I don't know how stable it is now.
Thanks again and Happy thanksgiving!
Yi
----- Original Message -----
From: "Oleg Kalnichevski" <ol...@apache.org>
To: "HttpClient User Discussion" <ht...@jakarta.apache.org>
Sent: Wednesday, November 24, 2004 12:40 AM
Subject: Re: HttpClient redirect to https locationy
> Yi,
>
> HttpClient 2.0.x can't handle cross-site redirects automatically (this
> limitation has already been fixed in HttpClient 3.0). However I can't
> see how this can be related to the problem you have been having, since
> you have explicitly disabled automatic redirects in your code.
>
> I may be of more help if you post the wire/context log of the HTTP
> session
>
> http://jakarta.apache.org/commons/httpclient/logging.html
>
> Oleg
>
> On Tue, Nov 23, 2004 at 04:09:44PM -0800, Yi Wang wrote:
> > Looks like the trick is here:
> >
> > [WARN] HttpMethodBase - -Redirect from protocol http to https is not
> > supported.
> >
> >
> > ----- Original Message -----
> > From: "Yi Wang" <yi...@cisco.com>
> > To: <ht...@jakarta.apache.org>
> > Sent: Monday, November 22, 2004 5:55 PM
> > Subject: HttpClient redirect to https location
> >
> >
> > Hi
> > I have a problem using the httpclient redirect features:
> > getMethod.setFollowRedirects(false);
> > status = httpClient.executeMethod(getMethod);
> > locationHeader = getMethod.getResponseHeader("location");
> > urlResult = locationHeader.getValue();
> > if (urlResult == null)
> > System.out.println("urlString is null");
> > else
> > System.out.println("urlResult is " + urlResult);
> > I always get a string :
> >
http://hostname:1741/nm/servlet/servlet.CsAuthServlet?cmd=loginSuccess&id=79
> >
DD6F6A83B89CA36CEC1BFB74845371&page=main?command=initializeAndValidate&url=/
> > cwhp/cwhp.applications.do&context=/cwhp&port=443
> >
> > But when using icesoft httpclient package I got the following:
> >
> >
https://hostname:443/nm/servlet/servlet.CsAuthServlet?cmd=loginSuccess&id=79
> >
DD6F6A83B89CA36CEC1BFB74845371&page=main?command=initializeAndValidate&url=/
> > cwhp/cwhp.applications.do&context=/cwhp&port=443
> >
> > As you can see, only the protocol name and port number are different.
And
> > the second string is correct.
> >
> > Here is the code using icesoft:
> >
> > ice.net.HttpURLConnection.setFollowRedirects(false);
> > ice.net.HttpURLConnection uc =
> > (ice.net.HttpURLConnection)url.openConnection();
> > uc.getContent();
> > status = uc.getResponseCode();
> >
> > //check if we get authenticated or get returned to the authFail
page
> > urlResult = uc.getHeaderField("Location");
> > ice.net.HttpURLConnection.setFollowRedirects(true);
> >
> > The second output was correct - can someone tell me how I should use the
> > httpclient package to generate the right output?
> >
> > Thanks
> >
> > Yi
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org