Author: chris.laprun(a)jboss.com
Date: 2007-06-12 18:35:10 -0400 (Tue, 12 Jun 2007)
New Revision: 7407
Modified:
trunk/common/src/main/org/jboss/portal/common/net/URLTools.java
Log:
- Added support for proxy in performGET. NOT TESTED!
Modified: trunk/common/src/main/org/jboss/portal/common/net/URLTools.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/net/URLTools.java 2007-06-12 09:59:57
UTC (rev 7406)
+++ trunk/common/src/main/org/jboss/portal/common/net/URLTools.java 2007-06-12 22:35:10
UTC (rev 7407)
@@ -28,8 +28,8 @@
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.common.util.ParameterValidation;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
@@ -55,19 +55,27 @@
public static final String FTP_PREFIX = "ftp://";
public static final String FILE_PREFIX = "/";
+ public static final int PROXY_PORT;
+ public static final String PROXY_HOST;
+
+ static
+ {
+ PROXY_HOST = System.getProperty("http.proxyHost");
+ PROXY_PORT = Integer.parseInt(System.getProperty("http.proxyPort"));
+ }
+
public static boolean isURLAbsolute(String url)
{
return isNetworkURL(url) || url.startsWith(FILE_PREFIX);
}
/**
- * Fetches content from an HTTP server performing a GET operation. If the status code
is 200
- * then it will return a byte array of the body otherwise returns null. The timeout
values
- * must not be negative integers, when it is equals to zero it means that it does not
setup
- * a timeout and use the default values.
+ * Fetches content from an HTTP server performing a GET operation. If the status code
is 200 then it will return a
+ * byte array of the body otherwise returns null. The timeout values must not be
negative integers, when it is equals
+ * to zero it means that it does not setup a timeout and use the default values.
*
- * @param url the URL the URL of the resource
- * @param soTimeoutMillis the socket connection timeout in millis
+ * @param url the URL the URL of the resource
+ * @param soTimeoutMillis the socket connection timeout in millis
* @param connTimeoutMillis the connection timeout in millis
* @return
*/
@@ -89,6 +97,8 @@
{
HttpClient client = new HttpClient();
+ client.getHostConfiguration().setProxy(PROXY_HOST, PROXY_PORT);
+
// Yes deprecated but advocated way to do will not for with 2.0.2 which is what
today JBoss AS ships
if (connTimeoutMillis > 0)
{
@@ -104,6 +114,7 @@
try
{
method = new GetMethod(url.toString());
+ method.setFollowRedirects(true);
int statusCode = client.executeMethod(method);
if (statusCode == 200)
{
Show replies by date