You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Samuel Cheung <SC...@Novarra.com> on 2002/04/28 04:56:13 UTC

Redirect problems in HTTP client of Jakarta Commons

Hi,

I am using the HTTPClient() to get the content of a site
"http://www.expedia.com", but I got the following exception saying
redirecting to a different host is not implemented. But when I use the URL
class in jdk, i am able to get the content of the site. Is it collect to say
HTTP client is build on top of the URL class in JDK, if yes, if I can access
site using the URL class, why I can't access site using HttpClient? Or Did I
do something in my problem below?

Thanks for any suggestion.


My program:

public static void main(String[] args) throws Exception {

		HttpClient hc = new HttpClient();
		UrlGetMethod ugm =  new
UrlGetMethod("http://www.expedia.com");

		hc.startSession(new URL("http://www.expedia.com"));

		hc.executeMethod(ugm);
}

The log file:
2002-04-27 21:50:16,296 [main] INFO  httpclient.wire - <<
"<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a
HREF="http://expedia.msn.com/Default.asp?FromServerName=www.expedia.com">her
e</a>.</body>
"
2002-04-27 21:50:16,306 [main] INFO
org.apache.commons.httpclient.HttpMethod - Server is attempting to redirect
a different host, which is currently not supported. Returning 302.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Redirect problems in HTTP client of Jakarta Commons

Posted by Luc Claes <lu...@posisoft.com>.
Oops!

(http://jdavmail.sourceforge.net, class JDAVMailStore, function 
> executeMethod())

> -----Original Message-----
> From: Luc Claes [mailto:luc@posisoft.com]
> Sent: Sunday, April 28, 2002 09:44
> To: Jakarta Commons Developers List
> Subject: RE: Redirect problems in HTTP client of Jakarta Commons
> 
> 
> Hi,
> 
> HttpClient currently doesn't support cross-host redirections (for 
> security reasons ?).
> You will have to implement the redirection mechanism yourself at 
> the application level.
> Such an implementation is available in the JDAVMail project
> (http://jdvamail.sourceforge.com, class JDAVMailStore, function 
> executeMethod())


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Redirect problems in HTTP client of Jakarta Commons

Posted by Luc Claes <lu...@posisoft.com>.
Hi,

HttpClient currently doesn't support cross-host redirections (for security reasons ?).
You will have to implement the redirection mechanism yourself at the application level.
Such an implementation is available in the JDAVMail project
(http://jdvamail.sourceforge.com, class JDAVMailStore, function executeMethod())



> -----Original Message-----
> From: Samuel Cheung [mailto:SCheung@Novarra.com]
> Sent: Sunday, April 28, 2002 04:56
> To: 'commons-dev@jakarta.apache.org'
> Subject: Redirect problems in HTTP client of Jakarta Commons
> 
> 
> Hi,
> 
> I am using the HTTPClient() to get the content of a site
> "http://www.expedia.com", but I got the following exception saying
> redirecting to a different host is not implemented. But when I use the URL
> class in jdk, i am able to get the content of the site. Is it 
> collect to say
> HTTP client is build on top of the URL class in JDK, if yes, if I 
> can access
> site using the URL class, why I can't access site using 
> HttpClient? Or Did I
> do something in my problem below?
> 
> Thanks for any suggestion.
> 
> 
> My program:
> 
> public static void main(String[] args) throws Exception {
> 
> 		HttpClient hc = new HttpClient();
> 		UrlGetMethod ugm =  new
> UrlGetMethod("http://www.expedia.com");
> 
> 		hc.startSession(new URL("http://www.expedia.com"));
> 
> 		hc.executeMethod(ugm);
> }
> 
> The log file:
> 2002-04-27 21:50:16,296 [main] INFO  httpclient.wire - <<
> "<head><title>Object moved</title></head>
> <body><h1>Object Moved</h1>This object may be found <a
> HREF="http://expedia.msn.com/Default.asp?FromServerName=www.expedi
> a.com">her
> e</a>.</body>
> "
> 2002-04-27 21:50:16,306 [main] INFO
> org.apache.commons.httpclient.HttpMethod - Server is attempting 
> to redirect
> a different host, which is currently not supported. Returning 302.
> 
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
> 
> 
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>