Author: keith
Date: Tue Jun 24 09:43:50 2008
New Revision: 18603
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=18603

Log:
Fixing Mashup-762



Modified:
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java?rev=18603&r1=18602&r2=18603&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java
  (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java
  Tue Jun 24 09:43:50 2008
@@ -21,12 +21,14 @@
 import com.sun.syndication.io.SyndFeedInput;
 import com.sun.syndication.io.XmlReader;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.context.MessageContext;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
 import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
 import org.apache.commons.httpclient.protocol.Protocol;
 import org.apache.commons.httpclient.methods.GetMethod;
@@ -44,6 +46,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.net.URI;
 
 /**
  * The FeedReader is a generic reader of Atom and RSS feeds.
@@ -87,18 +90,27 @@
             int statusCode;
             String feedUrl = (String) arguments[0];
 
-            HttpClient client = new HttpClient();
-
             // Create a method instance.
-            GetMethod method = new GetMethod(feedUrl);
+            GetMethod method = new GetMethod();
+
+            MultiThreadedHttpConnectionManager connectionManager =
+                new MultiThreadedHttpConnectionManager();
+            HttpClient httpClient = new HttpClient(connectionManager);
 
             try {
+                URL targetURL = new URL(feedUrl);
+
+                // We should not use method.setURI and set the complete URI 
here.
+                // If we do so commons-httpclient will not use our custom 
socket factory.
+                // Hence we set the path and query separatly
+                method.setPath(targetURL.getPath());
+                method.setQueryString(targetURL.getQuery());
+                method.setRequestHeader(HTTPConstants.HEADER_HOST, 
targetURL.getHost());
                 if (feedUrl.startsWith("https")) {
 
                     // If the feed is on https then we have to make sure we 
set the users keystore
                     // details into httpClient when making the call so that 
all sslHandshake stuff
                     // will go amoothly
-                    URL targetURL = new URL(feedUrl);
                     MessageContext currentMessageContext =
                             MessageContext.getCurrentMessageContext();
 
@@ -120,10 +132,10 @@
                     HostConfiguration config = new HostConfiguration();
                     config.setHost(targetURL.getHost(), port, protocol);
 
-                    statusCode = client.executeMethod(config, method);
+                    statusCode = httpClient.executeMethod(config, method);
                 } else {
                     // Execute the method.
-                    statusCode = client.executeMethod(method);
+                    statusCode = httpClient.executeMethod(method);
                 }
 
                 if (statusCode != HttpStatus.SC_OK) {

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to