portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r818122 - in /portals/applications/webcontent/trunk: webcontent-jar/ webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/ webcontent-war/src/main/webapp/WEB-INF/
Date Wed, 23 Sep 2009 14:42:24 GMT
Author: woonsan
Date: Wed Sep 23 14:42:24 2009
New Revision: 818122

URL: http://svn.apache.org/viewvc?rev=818122&view=rev
Log:
APA-17: Upgrading httpclient from the legacy 3.x version to the latest 4.0.

Modified:
    portals/applications/webcontent/trunk/webcontent-jar/pom.xml
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
    portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml

Modified: portals/applications/webcontent/trunk/webcontent-jar/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/pom.xml?rev=818122&r1=818121&r2=818122&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/pom.xml (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/pom.xml Wed Sep 23 14:42:24 2009
@@ -37,10 +37,13 @@
     <junit.version>3.8.1</junit.version>
     <nekohtml.version>0.9.5</nekohtml.version>
     <castor.version>1.1.1-xml</castor.version>
+    <httpcomponents-httpcore.version>4.0.1</httpcomponents-httpcore.version>
+    <httpcomponents-httpclient.version>4.0</httpcomponents-httpclient.version>
+    <jcip-annotations.version>1.0</jcip-annotations.version>
+    <json.version>20080701</json.version>
     <commons-lang.version>2.4</commons-lang.version>
     <commons-io.version>1.4</commons-io.version>
     <commons-httpclient.version>3.0.1</commons-httpclient.version>
-    <commons-fileupload.version>1.2</commons-fileupload.version>
     <commons-beanutils.version>1.7.0</commons-beanutils.version>
   </properties>
 
@@ -101,6 +104,29 @@
       <version>${nekohtml.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpcore</artifactId>
+      <version>${httpcomponents-httpcore.version}</version>
+    </dependency>
+    <!-- jcip-annotations is required to compile with httpclient and Java 1.5. See HTTPCLIENT-866. -->
+    <dependency>
+      <groupId>net.jcip</groupId>
+      <artifactId>jcip-annotations</artifactId>
+      <version>${jcip-annotations.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponents-httpclient.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
       <version>${commons-lang.version}</version>
@@ -126,14 +152,20 @@
       </exclusions>
     </dependency>
     <dependency>
-      <groupId>commons-fileupload</groupId>
-      <artifactId>commons-fileupload</artifactId>
-      <version>${commons-fileupload.version}</version>
-    </dependency>
-    <dependency>
       <groupId>commons-beanutils</groupId>
       <artifactId>commons-beanutils</artifactId>
       <version>${commons-beanutils.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.json</groupId>
+      <artifactId>json</artifactId>
+      <version>${json.version}</version>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>

Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java?rev=818122&r1=818121&r2=818122&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java Wed Sep 23 14:42:24 2009
@@ -16,17 +16,14 @@
  */
 package org.apache.portals.applications.webcontent.proxy.impl;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URI;
+import java.net.InetAddress;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Iterator;
+import java.util.HashMap;
 import java.util.List;
-import java.util.Properties;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -36,19 +33,30 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.collections.KeyValue;
 import org.apache.commons.collections.keyvalue.DefaultKeyValue;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.LineIterator;
 import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpHost;
+import org.apache.http.client.params.ClientParamBean;
+import org.apache.http.conn.params.ConnManagerParamBean;
+import org.apache.http.conn.params.ConnPerRouteBean;
+import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.conn.routing.RouteInfo;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyPathMapper;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyPathMapperProvider;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyService;
 import org.apache.portals.applications.webcontent.rewriter.MappingRewriterController;
 import org.apache.portals.applications.webcontent.rewriter.Rewriter;
 import org.apache.portals.applications.webcontent.rewriter.RewriterController;
-import org.apache.portals.applications.webcontent.rewriter.WebContentRewriter;
-import org.apache.portals.applications.webcontent.rewriter.html.neko.NekoParserAdaptor;
-import org.apache.portals.applications.webcontent.rewriter.xml.SaxParserAdaptor;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,11 +73,29 @@
     
     protected HttpReverseProxyPathMapperProvider proxyPathMapperProvider;
     protected HttpReverseProxyService proxyService;
-
+    
+    private List<Class> rewriterClassList;
+    private List<Class> adaptorClassList;
+    
     @Override
     public void init(ServletConfig config) throws ServletException
     {
         List<HttpReverseProxyPathMapper> proxyPathMappers = new ArrayList<HttpReverseProxyPathMapper>();
+        
+        List<Class> classList = buildClassList(config.getInitParameter("reverseproxy.rewriter.classes"));
+        
+        if (classList != null)
+        {
+            rewriterClassList = classList;
+        }
+        
+        classList = buildClassList(config.getInitParameter("reverseproxy.adaptor.classes"));
+        
+        if (classList != null)
+        {
+            adaptorClassList = classList;
+        }
+        
         List<KeyValue> rewriterControllerPairs = new ArrayList<KeyValue>();
         List<KeyValue> rewriterPairs = new ArrayList<KeyValue>();
 
@@ -80,72 +106,73 @@
             Pattern reverseProxyPathURLPattern = Pattern.compile("^ReverseProxyPathURL\\s+(\\S+)\\s+(\\S+)$", Pattern.CASE_INSENSITIVE);
             Pattern reverseProxyRewriterPattern = Pattern.compile("^ReverseProxyRewriter\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)$", Pattern.CASE_INSENSITIVE);
             
-            List lines = readLines(config, urlMappings, null);
+            InputStream urlMappingsInput = null;
             
-            for (Iterator it = lines.iterator(); it.hasNext(); )
+            try
             {
-                String line = ((String) it.next()).trim();
+                urlMappingsInput = config.getServletContext().getResourceAsStream(urlMappings);
+                LineIterator lineIt = IOUtils.lineIterator(urlMappingsInput, null);
                 
-                if ("".equals(line) || line.startsWith("#"))
+                while (lineIt.hasNext())
                 {
-                    continue;
-                }
-                
-                Matcher reverseProxyPathURLMatcher = reverseProxyPathURLPattern.matcher(line);
-                Matcher reverseProxyRewriterMatcher = reverseProxyRewriterPattern.matcher(line);
+                    String line = lineIt.nextLine();
                 
-                if (reverseProxyPathURLMatcher.matches())
-                {
-                    String localBasePath = reverseProxyPathURLMatcher.group(1);
-                    String remoteBaseURL = reverseProxyPathURLMatcher.group(2);
-                    HttpReverseProxyPathMapper proxyPathMapper = new DefaultHttpProxyPathMapperImpl(localBasePath, remoteBaseURL);
-                    proxyPathMappers.add(proxyPathMapper);
-                }
-                else if (reverseProxyRewriterMatcher.matches())
-                {
-                    String localBasePath = reverseProxyRewriterMatcher.group(1);
-                    String rulesMapping = reverseProxyRewriterMatcher.group(2);
-                    String rewriterRules = reverseProxyRewriterMatcher.group(3);
+                    if ("".equals(line) || line.startsWith("#"))
+                    {
+                        continue;
+                    }
                     
-                    try
+                    Matcher reverseProxyPathURLMatcher = reverseProxyPathURLPattern.matcher(line);
+                    Matcher reverseProxyRewriterMatcher = reverseProxyRewriterPattern.matcher(line);
+                    
+                    if (reverseProxyPathURLMatcher.matches())
                     {
-                        RewriterController rewriterController = createRewriterController(config, rulesMapping);
-                        rewriterControllerPairs.add(new DefaultKeyValue(localBasePath, rewriterController));
-                        Rewriter rewriter = createRewriter(config, rewriterController, rewriterRules);
-                        rewriterPairs.add(new DefaultKeyValue(localBasePath, rewriter));
+                        String localBasePath = reverseProxyPathURLMatcher.group(1);
+                        String remoteBaseURL = reverseProxyPathURLMatcher.group(2);
+                        HttpReverseProxyPathMapper proxyPathMapper = new DefaultHttpProxyPathMapperImpl(localBasePath, remoteBaseURL);
+                        proxyPathMappers.add(proxyPathMapper);
                     }
-                    catch (Exception e)
+                    else if (reverseProxyRewriterMatcher.matches())
                     {
-                        throw new ServletException(e);
+                        String localBasePath = reverseProxyRewriterMatcher.group(1);
+                        String rulesMapping = reverseProxyRewriterMatcher.group(2);
+                        String rewriterRules = reverseProxyRewriterMatcher.group(3);
+                        
+                        try
+                        {
+                            RewriterController rewriterController = createRewriterController(config, rulesMapping);
+                            
+                            if (rewriterController != null)
+                            {
+                                rewriterControllerPairs.add(new DefaultKeyValue(localBasePath, rewriterController));
+                                Rewriter rewriter = createRewriter(config, rewriterController, rewriterRules);
+                                rewriterPairs.add(new DefaultKeyValue(localBasePath, rewriter));
+                            }
+                        }
+                        catch (Exception e)
+                        {
+                            throw new ServletException(e);
+                        }
                     }
                 }
             }
-        }
-        
-        proxyPathMapperProvider = new DefaultHttpReverseProxyPathMapperProviderImpl(proxyPathMappers, rewriterControllerPairs, rewriterPairs);
-        proxyService = new RewritableHttpReverseProxyServiceImpl(proxyPathMapperProvider);
-        
-        String param = config.getInitParameter("reverseproxy.fileuploaddir");
-        
-        if (param != null)
-        {
-            param = param.trim();
-            
-            if (param.startsWith("file:"))
-            {
-                ((RewritableHttpReverseProxyServiceImpl) proxyService).setFileUploadDir(new File(URI.create(param)));
-            }
-            else if (param.startsWith("/"))
+            catch (IOException e)
             {
-                ((RewritableHttpReverseProxyServiceImpl) proxyService).setFileUploadDir(new File(config.getServletContext().getRealPath(param)));
+                throw new ServletException("Failed to initialize url mappings. " + e);
             }
-            else
+            finally
             {
-                ((RewritableHttpReverseProxyServiceImpl) proxyService).setFileUploadDir(new File(param));
+                if (urlMappingsInput != null)
+                {
+                    IOUtils.closeQuietly(urlMappingsInput);
+                }
             }
         }
         
-        param = config.getInitParameter("reverseproxy.hostheadervalue");
+        proxyPathMapperProvider = new DefaultHttpReverseProxyPathMapperProviderImpl(proxyPathMappers, rewriterControllerPairs, rewriterPairs);
+        proxyService = new RewritableHttpReverseProxyServiceImpl(proxyPathMapperProvider);
+        
+        String param = config.getInitParameter("reverseproxy.hostheadervalue");
         
         if (param != null)
         {
@@ -159,13 +186,6 @@
             ((RewritableHttpReverseProxyServiceImpl) proxyService).setLocalBaseURL(param.trim());
         }
         
-        param = config.getInitParameter("reverseproxy.maxfileuploadsize");
-        
-        if (param != null)
-        {
-            ((RewritableHttpReverseProxyServiceImpl) proxyService).setMaxFileUploadSize(Integer.parseInt(param.trim()));
-        }
-        
         param = config.getInitParameter("reverseproxy.prependlocalbaseurl");
         
         if (param != null)
@@ -173,30 +193,107 @@
             ((RewritableHttpReverseProxyServiceImpl) proxyService).setPrependLocalBaseURL(BooleanUtils.toBoolean(param.trim()));
         }
         
-        param = config.getInitParameter("reverseproxy.cookiepolicy");
-        
-        if (param != null)
-        {
-            ((RewritableHttpReverseProxyServiceImpl) proxyService).setCookiePolicy(param.trim());
-        }
-        
-        Properties connectionProperties = new Properties();
+        boolean clientParamSet = false;
+        HttpParams clientParams = new BasicHttpParams();
+        ClientParamBean clientParamBean = new ClientParamBean(clientParams);
+        
+        boolean requestParamSet = false;
+        HttpParams requestParams = new BasicHttpParams();
+        ClientParamBean requestParamBean = new ClientParamBean(requestParams);
+        
+        boolean connManagerParamSet = false;
+        HttpParams connManagerParams = new BasicHttpParams();
+        ConnManagerParamBean connManagerParamBean = new ConnManagerParamBean(connManagerParams);
+        
+        boolean connPerRouteParamSet = false;
+        ConnPerRouteBean connPerRouteBean = new ConnPerRouteBean();
+        Map<HttpRoute, Integer> maxForRoutes = new HashMap<HttpRoute, Integer>();
         
         for (Enumeration enumParamNames = config.getInitParameterNames(); enumParamNames.hasMoreElements(); )
         {
             String paramName = (String) enumParamNames.nextElement();
             
-            if (paramName.startsWith("connection.property."))
+            try
             {
-                String propName = paramName.substring("connection.property.".length());
-                String paramValue = config.getInitParameter(paramName);
-                connectionProperties.setProperty(propName, paramValue);
+                if (paramName.startsWith("client.param."))
+                {
+                    String propName = paramName.substring("client.param.".length());
+                    String paramValue = config.getInitParameter(paramName);
+                    BeanUtils.setProperty(clientParamBean, propName, paramValue);
+                    clientParamSet = true;
+                }
+                else if (paramName.startsWith("request.param."))
+                {
+                    String propName = paramName.substring("request.param.".length());
+                    String paramValue = config.getInitParameter(paramName);
+                    BeanUtils.setProperty(requestParamBean, propName, paramValue);
+                    requestParamSet = true;
+                }
+                else if (paramName.startsWith("conn.manager.param."))
+                {
+                    String propName = paramName.substring("conn.manager.param.".length());
+                    String paramValue = config.getInitParameter(paramName);
+                    BeanUtils.setProperty(connManagerParamBean, propName, paramValue);
+                    connManagerParamSet = true;
+                }
+                else if (paramName.startsWith("conn.per.route.param."))
+                {
+                    String propName = paramName.substring("conn.per.route.param.".length());
+                    String paramValue = config.getInitParameter(paramName);
+                    
+                    if ("maxForRoutes".equals(propName))
+                    {
+                        JSONArray routes = new JSONObject(paramValue).getJSONArray("routes");
+                        
+                        for (int i = 0; i < routes.length(); i++)
+                        {
+                            JSONObject route = routes.getJSONObject(i);
+                            HttpRoute httpRoute = buildHttpRoute(route);
+                            int maxForRoute = route.getInt("max");
+                            maxForRoutes.put(httpRoute, new Integer(maxForRoute));
+                        }
+                        
+                        connPerRouteBean.setMaxForRoutes(maxForRoutes);
+                    }
+                    else
+                    {
+                        BeanUtils.setProperty(connPerRouteBean, propName, paramValue);
+                    }
+                    
+                    connPerRouteParamSet = true;
+                }
             }
+            catch (Exception e)
+            {
+                if (log.isDebugEnabled())
+                {
+                    log.error("Failed to set parameter named " + paramName, e);
+                }
+                else
+                {
+                    log.error("Failed to set parameter named {}. {}", paramName, e);
+                }
+            }
+        }
+        
+        if (clientParamSet)
+        {
+            ((RewritableHttpReverseProxyServiceImpl) proxyService).setClientParams(clientParams);
         }
         
-        if (!connectionProperties.isEmpty())
+        if (requestParamSet)
         {
-            ((RewritableHttpReverseProxyServiceImpl) proxyService).setConnectionProperties(connectionProperties);
+            ((RewritableHttpReverseProxyServiceImpl) proxyService).setRequestParams(requestParams);
+        }
+        
+        if (connManagerParamSet || connPerRouteParamSet)
+        {
+            if (connPerRouteParamSet)
+            {
+                connManagerParamBean.setConnectionsPerRoute(connPerRouteBean);
+            }
+            
+            ((RewritableHttpReverseProxyServiceImpl) proxyService).setConnectionManagerParams(connManagerParams);
         }
         
         proxyService.initialize();
@@ -222,76 +319,198 @@
         doGet(request, response);
     }
     
-    private List readLines(ServletConfig config, String resourceContextRelativePath, String encoding)
+    private RewriterController createRewriterController(ServletConfig config, String rulesMappingResourcePath) throws Exception
+    {
+        if (rewriterClassList != null && adaptorClassList != null)
+        {
+            return new MappingRewriterController(config.getServletContext().getRealPath(rulesMappingResourcePath), rewriterClassList, adaptorClassList);
+        }
+        else
+        {
+            return null;
+        }
+    }
+    
+    private Rewriter createRewriter(ServletConfig config, RewriterController rwc, String rewriterRulesResourcePath) throws Exception
     {
-        List lines = null;
-        InputStream input = null;
+        Rewriter rewriter = null;
+        InputStream rewriterRulesInput = null;
+        
+        try
+        {
+            rewriterRulesInput = config.getServletContext().getResourceAsStream(rewriterRulesResourcePath);
+            rewriter = rwc.createRewriter(rwc.loadRuleset(rewriterRulesInput));
+        }
+        finally
+        {
+            if (rewriterRulesInput != null)
+            {
+                IOUtils.closeQuietly(rewriterRulesInput);
+            }
+        }
+        
+        return rewriter;
+    }
+    
+    private HttpRoute buildHttpRoute(JSONObject route) throws Exception
+    {
+        HttpRoute httpRoute = null;
+        
+        HttpHost targetHost = null;
+        InetAddress localAddress = null;
+        HttpHost [] proxyHosts = null;
+        boolean secure = false;
+        String tunnelled = null;
+        String layered = null;
+        RouteInfo.TunnelType tunnelType = RouteInfo.TunnelType.PLAIN;
+        RouteInfo.LayerType layerType = RouteInfo.LayerType.PLAIN;
+        
+        targetHost = buildHttpHost(route.getJSONObject("target"));
         
         try 
         {
-            input = config.getServletContext().getResourceAsStream(resourceContextRelativePath);
-            lines = IOUtils.readLines(input, encoding);
+            String local = route.getString("local");
+            
+            if (local != null)
+            {
+                localAddress = InetAddress.getByAddress(local.getBytes());
+            }
         }
-        catch (IOException e)
+        catch (Exception e)
         {
-            log.error("Failed to read resource: " + resourceContextRelativePath + ". " + e);
         }
-        finally
+        
+        try 
         {
-            if (input != null)
+            JSONArray proxies = route.getJSONArray("proxies");
+            
+            if (proxies != null)
             {
-                try 
-                {
-                    input.close();
-                }
-                catch (Exception ce)
+                proxyHosts = new HttpHost[proxies.length()];
+                
+                for (int i = 0; i < proxies.length(); i++)
                 {
+                    proxyHosts[i] = buildHttpHost(proxies.getJSONObject(i));
                 }
             }
         }
+        catch (Exception e)
+        {
+        }
+        
+        try 
+        {
+            secure = route.getBoolean("secure");
+        }
+        catch (Exception e)
+        {
+        }
+        
+        try 
+        {
+            tunnelled = route.getString("tunnelled");
+            
+            if (tunnelled != null)
+            {
+                tunnelType = RouteInfo.TunnelType.valueOf(tunnelled);
+            }
+        }
+        catch (Exception e)
+        {
+        }
         
-        return Collections.unmodifiableList(lines != null ? lines : Collections.emptyList());
+        try 
+        {
+            layered = route.getString("layered");
+            
+            if (layered != null)
+            {
+                layerType = RouteInfo.LayerType.valueOf(layered);
+            }
+        }
+        catch (Exception e) 
+        {
+        }
+        
+        if (localAddress == null)
+        {
+            httpRoute = new HttpRoute(targetHost);
+        }
+        else if (proxyHosts == null)
+        {
+            httpRoute = new HttpRoute(targetHost, localAddress, secure);
+        }
+        else
+        {
+            httpRoute = new HttpRoute(targetHost, localAddress, proxyHosts, secure, tunnelType, layerType);
+        }
+        
+        return httpRoute;
     }
     
-    private RewriterController createRewriterController(ServletConfig config, String rulesMappingResourcePath) throws Exception
+    private HttpHost buildHttpHost(JSONObject host)
     {
-        RewriterController rwc = null;
+        HttpHost httpHost = null;
         
-        Class [] rewriterClasses = new Class[] { WebContentRewriter.class, WebContentRewriter.class};
-        Class [] adaptorClasses = new Class[] { NekoParserAdaptor.class, SaxParserAdaptor.class};
+        String hostname = null;
+        int port = 0;
+        String scheme = null;
         
-        rwc = new MappingRewriterController(config.getServletContext().getRealPath(rulesMappingResourcePath), 
-                                            Arrays.asList(rewriterClasses), 
-                                            Arrays.asList(adaptorClasses));
+        try { hostname = host.getString("hostname"); } catch (JSONException e) { }
+        try { port = host.getInt("port"); } catch (JSONException e) { }
+        try { scheme = host.getString("scheme"); } catch (JSONException e) { }
         
-        return rwc;
+        if (hostname == null)
+        {
+            throw new IllegalArgumentException("hostname is null: " + host);
+        }
+        
+        if (port <= 0)
+        {
+            httpHost = new HttpHost(hostname);
+        }
+        else if (scheme == null)
+        {
+            httpHost = new HttpHost(hostname, port);
+        }
+        else
+        {
+            httpHost = new HttpHost(hostname, port, scheme);
+        }
+        
+        return httpHost;
     }
     
-    private Rewriter createRewriter(ServletConfig config, RewriterController rwc, String rewriterRulesResourcePath) throws Exception
+    private List<Class> buildClassList(String list)
     {
-        Rewriter rewriter = null;
-        InputStream rewriterRulesInput = null;
+        String [] classNames = StringUtils.split(list);
         
-        try
+        if (classNames != null)
         {
-            rewriterRulesInput = config.getServletContext().getResourceAsStream(rewriterRulesResourcePath);
-            rewriter = rwc.createRewriter(rwc.loadRuleset(rewriterRulesInput));
-        }
-        finally
-        {
-            if (rewriterRulesInput != null)
+            List<Class> classList = new ArrayList();
+            
+            for (String className : classNames)
             {
-                try 
+                try
                 {
-                    rewriterRulesInput.close();
+                    classList.add(Thread.currentThread().getContextClassLoader().loadClass(className));
                 }
-                catch (Exception ce) 
+                catch (Exception e)
                 {
+                    if (log.isDebugEnabled())
+                    {
+                        log.error("Failed to load class: " + className, e);
+                    }
+                    else
+                    {
+                        log.error("Failed to load class: {}. {}", className, e);
+                    }
                 }
             }
+            
+            return classList;
         }
         
-        return rewriter;
+        return null;
     }
-    
 }

Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java?rev=818122&r1=818121&r2=818122&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java Wed Sep 23 14:42:24 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.portals.applications.webcontent.proxy.impl;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -24,41 +23,30 @@
 import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
-import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.fileupload.disk.DiskFileItem;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.URI;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.FilePartSource;
-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.PartSource;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
-import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
 import org.apache.commons.io.IOUtils;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.params.ClientPNames;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.EntityUtils;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyPathMapper;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyPathMapperProvider;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyService;
@@ -85,12 +73,10 @@
     
     private static final String LOCATION_HEADER = "Location";
     
-    private static final String CONTENT_TYPE_HEADER = "Content-Type";
-    
     private static final String CONTENT_LENGTH_HEADER = "Content-Length";
     
     private static final String HOST_HEADER = "Host";
-
+    
     /**
      * Proxy path mapper provider
      */
@@ -112,30 +98,25 @@
     private boolean prependLocalBaseURL;
     
     /**
-     * Maximum file upload size
+     * The shared http client for performance.
      */
-    private int maxFileUploadSize;
+    private HttpClient httpClient;
     
     /**
-     * File upload directory
+     * HTTP Client Parameters
      */
-    private File fileUploadDir;
+    private HttpParams clientParams;
     
     /**
-     * Cookie policy
+     * HTTP Connection Manager Parameters
      */
-    private String cookiePolicy = CookiePolicy.IGNORE_COOKIES;
-    
+    private HttpParams connectionManagerParams;
+
     /**
-     * The shared http client for performance.
+     * HTTP Request Parameters
      */
-    private HttpClient httpClient;
+    private HttpParams requestParams;
     
-    /**
-     * HTTP Connection Parameters
-     */
-    private Properties connectionProperties;
-
     public RewritableHttpReverseProxyServiceImpl(HttpReverseProxyPathMapperProvider proxyPathMapperProvider)
     {
         this.proxyPathMapperProvider = proxyPathMapperProvider;
@@ -156,76 +137,50 @@
         this.prependLocalBaseURL = prependLocalBaseURL;
     }
     
-    public void setMaxFileUploadSize(int maxFileUploadSize)
-    {
-        this.maxFileUploadSize = maxFileUploadSize;
-    }
-    
-    public void setFileUploadDir(File fileUploadDir)
+    public void setClientParams(HttpParams clientParams)
     {
-        this.fileUploadDir = fileUploadDir;
+        this.clientParams = clientParams;
     }
     
-    public void setCookiePolicy(String cookiePolicy)
+    public void setConnectionManagerParams(HttpParams connectionManagerParams)
     {
-        this.cookiePolicy = cookiePolicy;
+        this.connectionManagerParams = connectionManagerParams;
     }
     
-    public void setConnectionProperties(Properties connectionProperties)
+    public void setRequestParams(HttpParams requestParams)
     {
-        this.connectionProperties = connectionProperties;
+        this.requestParams = requestParams;
     }
     
     public void initialize()
     {
-        MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
-        HttpConnectionManagerParams connectionManagerParams = connectionManager.getParams();
-        
-        if (connectionProperties != null)
+        if (clientParams == null && connectionManagerParams == null)
         {
-            for (Enumeration enumPropNames = connectionProperties.propertyNames(); enumPropNames.hasMoreElements(); )
-            {
-                String propName = (String) enumPropNames.nextElement();
-                String propValue = connectionProperties.getProperty(propName);
-                
-                try
-                {
-                    if (propName.startsWith("maxConnectionsPerHost."))
-                    {
-                        int offset = "maxConnectionsPerHost.".length();
-                        String hostURI = propName.substring(offset);
-                        HostConfiguration hostConfig = new HostConfiguration();
-                        hostConfig.setHost(new URI(hostURI, false));
-                        int maxConnectionsPerHost = Integer.parseInt(propValue);
-                        connectionManagerParams.setMaxConnectionsPerHost(hostConfig, maxConnectionsPerHost);
-                    }
-                    else
-                    {
-                        BeanUtils.setProperty(connectionManagerParams, propName, propValue);
-                    }
-                }
-                catch (Exception e)
-                {
-                    if (log.isDebugEnabled())
-                    {
-                        log.error("Cannot set property. " + propName + " = " + propValue, e);
-                    }
-                    else
-                    {
-                        log.error("Cannot set property. " + propName + " = " + propValue + ". {}", e);
-                    }
-                }
-            }
+            clientParams = connectionManagerParams = new BasicHttpParams();
         }
+        else if (clientParams == null)
+        {
+            clientParams = new BasicHttpParams();
+        }
+        else if (connectionManagerParams == null)
+        {
+            connectionManagerParams = new BasicHttpParams();
+        }
+        
+        SchemeRegistry schemeRegistry = new SchemeRegistry();
+        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+        schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
+
+        ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(connectionManagerParams, schemeRegistry);
         
-        httpClient = new HttpClient(connectionManager);
+        httpClient = new DefaultHttpClient(connectionManager, clientParams);
     }
     
     public void destroy()
     {
         if (httpClient != null)
         {
-            ((MultiThreadedHttpConnectionManager) httpClient.getHttpConnectionManager()).shutdown();
+            ((ThreadSafeClientConnManager) httpClient.getConnectionManager()).shutdown();
         }
         
         httpClient = null;
@@ -272,74 +227,84 @@
             throw new IllegalStateException("Cannot translate the location path info into remote URL. " + pathInfo);
         }
         
+        String queryString = request.getQueryString();
+        
+        if (queryString != null)
+        {
+            proxyTargetURL = new StringBuilder(proxyTargetURL.length() + 1 + queryString.length()).append(proxyTargetURL).append('?').append(queryString).toString();
+        }
+        
         String method = request.getMethod();
         boolean isGetMethod = "GET".equals(method);
         boolean isPostMethod = "POST".equals(method);
-        boolean isPostMultipartMethod = isPostMethod && ServletFileUpload.isMultipartContent(request);
         
-        HttpMethodBase httpMethodForProxyRequest = null;
+        HttpRequestBase httpRequest = null;
         
         if (isGetMethod)
         {
-            httpMethodForProxyRequest = new GetMethod(proxyTargetURL);
+            httpRequest = new HttpGet(proxyTargetURL);
         }
         else if (isPostMethod)
         {
-            httpMethodForProxyRequest = new PostMethod(proxyTargetURL);
-            
-            if (isPostMultipartMethod)
-            {
-                postMultipartParams((PostMethod) httpMethodForProxyRequest, request);
-            }
-            else
-            {
-                postFormParams((PostMethod) httpMethodForProxyRequest, request);
-            }
+            httpRequest = new HttpPost(proxyTargetURL);
+            HttpEntity entity = new InputStreamEntity(request.getInputStream(), 4096);
+            ((HttpPost) httpRequest).setEntity(entity);
         }
         else
         {
             throw new IOException("Unsupported method: " + method);
         }
         
-        if (cookiePolicy != null)
+        if (requestParams != null)
         {
-            httpMethodForProxyRequest.getParams().setCookiePolicy(cookiePolicy);
+            httpRequest.setParams(requestParams);
         }
         
         // redirection should be adjusted with local host header...
-        httpMethodForProxyRequest.setFollowRedirects(false);
-        
-        String queryString = request.getQueryString();
+        httpRequest.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
         
-        if (queryString != null)
+        // pass most headers to proxy target...
+        for (Enumeration enumHeaderNames = request.getHeaderNames(); enumHeaderNames.hasMoreElements(); ) 
         {
-            httpMethodForProxyRequest.setQueryString(queryString);
+            String headerName = (String) enumHeaderNames.nextElement();
+            
+            if (headerName.equalsIgnoreCase(CONTENT_LENGTH_HEADER))
+                continue;
+            
+            if (headerName.equalsIgnoreCase(HOST_HEADER))
+                continue;
+            
+            for (Enumeration enumHeaderValues = request.getHeaders(headerName); enumHeaderValues.hasMoreElements(); )
+            {
+                String headerValue = (String) enumHeaderValues.nextElement();
+                httpRequest.addHeader(headerName, headerValue);
+            }
         }
         
-        setProxyRequestHeaders(httpMethodForProxyRequest, request);
-        
-        if (isPostMultipartMethod)
-        {
-            postMultipartParams((PostMethod) httpMethodForProxyRequest, request);
-        }
-        else if (isPostMethod)
-        {
-            postFormParams((PostMethod) httpMethodForProxyRequest, request);
-        }
+        HttpEntity httpEntity = null;
         
         try
         {
-            int proxyResponseCode = httpClient.executeMethod(httpMethodForProxyRequest);
+            HttpResponse httpResponse = httpClient.execute(httpRequest);
+            httpEntity = httpResponse.getEntity();
+            
+            int statusCode = httpResponse.getStatusLine().getStatusCode();
             
             // Check if the proxy response is a redirect
-            if (proxyResponseCode >= HttpServletResponse.SC_MULTIPLE_CHOICES /* 300 */
-                && proxyResponseCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */)
+            if (statusCode >= HttpServletResponse.SC_MULTIPLE_CHOICES /* 300 */
+                && statusCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */)
             {
-                String location = httpMethodForProxyRequest.getResponseHeader(LOCATION_HEADER).getValue();
+                String location = null;
+                Header locationHeader = httpResponse.getFirstHeader(LOCATION_HEADER);
+                
+                if (locationHeader != null)
+                {
+                    location = locationHeader.getValue();
+                }
                 
                 if (location == null)
                 {
-                    throw new IOException("Recieved status code: " + proxyResponseCode + " but no " + LOCATION_HEADER + " header was found in the response");
+                    throw new IOException("Recieved status code: " + statusCode + " but no " + LOCATION_HEADER + " header was found in the response");
                 }
                 
                 // Modify the redirect to go to this proxy servlet rather that the proxied host
@@ -382,7 +347,7 @@
                 
                 return;
             }
-            else if (proxyResponseCode == HttpServletResponse.SC_NOT_MODIFIED)
+            else if (statusCode == HttpServletResponse.SC_NOT_MODIFIED)
             {
                 // 304 needs special handling. See:
                 // http://www.ics.uci.edu/pub/ietf/http/rfc1945.html#Code304
@@ -395,36 +360,62 @@
                 
                 return;
             }
-            
-            // Pass the response code back to the client
-            response.setStatus(proxyResponseCode);
-            
-            String responseContentType = null;
-            
-            // Pass response headers back to the client
-            Header[] headerArrayResponse = httpMethodForProxyRequest.getResponseHeaders();
-            
-            for (Header header : headerArrayResponse)
+            else
             {
-                response.setHeader(header.getName(), header.getValue());
+                // Pass the response code back to the client
+                response.setStatus(statusCode);
                 
-                if (responseContentType == null && header.getName().equalsIgnoreCase(CONTENT_TYPE_HEADER))
+                if (httpEntity != null)
                 {
-                    responseContentType = header.getValue();
+                    // Pass response headers back to the client
+                    Header [] headerArrayResponse = httpResponse.getAllHeaders();
+                    
+                    for (Header header : headerArrayResponse)
+                    {
+                        String headerName = header.getName();
+                        String headerValue = header.getValue();
+                        
+                        if (headerName.equalsIgnoreCase(HOST_HEADER))
+                        {
+                            response.setHeader(headerName, hostHeaderValue);
+                        }
+                        else
+                        {
+                            response.setHeader(headerName, headerValue);
+                        }
+                    }
+                    
+                    // Send the content to the client
+                    writeHttpEntityToClient(request, response, httpEntity);
                 }
             }
+        }
+        catch (Exception e)
+        {
+            if (log.isDebugEnabled())
+            {
+                log.error("Exception occurred during execution for " + proxyTargetURL, e);
+            }
+            else
+            {
+                log.error("Exception occurred during execution for {} {}", proxyTargetURL, e);
+            }
+            
+            httpRequest.abort();
+            httpEntity = null;
             
-            // Send the content to the client
-            sendContentToClient(request, response, httpMethodForProxyRequest, responseContentType);
+            throw new IOException(e.getLocalizedMessage());
         }
         finally
         {
-            // be sure the connection is released back to the connection manager...
-            httpMethodForProxyRequest.releaseConnection();
+            if (httpEntity != null)
+            {
+                httpEntity.consumeContent();
+            }
         }
     }
     
-    private void sendContentToClient(HttpServletRequest request, HttpServletResponse response, HttpMethodBase httpMethodForProxyRequest, String responseContentType) throws IOException
+    private void writeHttpEntityToClient(HttpServletRequest request, HttpServletResponse response, HttpEntity httpEntity) throws IOException
     {
         InputStream in = null;
         Reader reader = null;
@@ -433,7 +424,7 @@
         
         try 
         {
-            in = httpMethodForProxyRequest.getResponseBodyAsStream();
+            in = httpEntity.getContent();
             
             // According to javadoc of httpclient, getResponseBodyAsStream() can return null
             // if the response has no body.
@@ -451,24 +442,31 @@
                 }
                 else
                 {
-                    String mimeTypeForParserAdaptor = "text/html";
+                    String mimeType = "text/html";
+                    String contentType = null;
+                    Header contentTypeHeader = httpEntity.getContentType();
+                    
+                    if (contentTypeHeader != null)
+                    {
+                        contentType = contentTypeHeader.getValue();
+                    }
                     
-                    if (responseContentType != null)
+                    if (contentType != null)
                     {
-                        int offset = responseContentType.indexOf(';');
+                        int offset = contentType.indexOf(';');
                         
                         if (offset > 0)
                         {
-                            mimeTypeForParserAdaptor = mimeTypeForParserAdaptor.substring(0, offset).trim();
+                            mimeType = contentType.substring(0, offset).trim();
                         }
                         else
                         {
-                            mimeTypeForParserAdaptor = responseContentType;
+                            mimeType = contentType;
                         }
                     }
                     
-                    ParserAdaptor parserAdaptor = rewriterController.createParserAdaptor(mimeTypeForParserAdaptor);
-                    String responseCharSet = httpMethodForProxyRequest.getResponseCharSet();
+                    ParserAdaptor parserAdaptor = rewriterController.createParserAdaptor(mimeType);
+                    String responseCharSet = EntityUtils.getContentCharSet(httpEntity);
                     
                     if (responseCharSet != null)
                     {
@@ -488,147 +486,35 @@
         }
         catch (RewriterException e)
         {
+            if (log.isDebugEnabled())
+            {
+                log.error("Exception occurred during writing content.", e);
+            }
+            else
+            {
+                log.error("Exception occurred during writing content. {}", e.toString());
+            }
+
             throw new IOException(e.getLocalizedMessage());
         }
         finally
         {
             if (reader != null)
             {
-                try { reader.close(); } catch (Exception ce) { }
+                IOUtils.closeQuietly(reader);
             }
             if (in != null)
             {
-                try { in.close(); } catch (Exception ce) { }
+                IOUtils.closeQuietly(in);
             }
             if (writer != null)
             {
-                try { writer.close(); } catch (Exception ce) { }
+                IOUtils.closeQuietly(writer);
             }
             if (out != null)
             {
-                try { out.close(); } catch (Exception ce) { }
-            }
-        }
-    }
-
-    private void setProxyRequestHeaders(HttpMethod httpMethodForProxyRequest, HttpServletRequest request) 
-    {
-        // Get an Enumeration of all of the header names sent by the client
-        for (Enumeration enumHeaderNames = request.getHeaderNames(); enumHeaderNames.hasMoreElements(); ) 
-        {
-            String headerName = (String) enumHeaderNames.nextElement();
-            
-            if (headerName.equalsIgnoreCase(CONTENT_LENGTH_HEADER))
-                continue;
-            
-            // As per the Java Servlet API 2.5 documentation:
-            //      Some headers, such as Accept-Language can be sent by clients
-            //      as several headers each with a different value rather than
-            //      sending the header as a comma separated list.
-            // Thus, we get an Enumeration of the header values sent by the client
-            
-            for (Enumeration enumHeaderValues = request.getHeaders(headerName); enumHeaderValues.hasMoreElements(); )
-            {
-                String headerValue = (String) enumHeaderValues.nextElement();
-                
-                // In case the proxy host is running multiple virtual servers,
-                // rewrite the Host header to ensure that we get content from
-                // the correct virtual server
-                if (headerName.equalsIgnoreCase(HOST_HEADER))
-                {
-                    headerValue = hostHeaderValue;
-                }
-                
-                Header header = new Header(headerName, headerValue);
-                
-                // Set the same header on the proxy request
-                httpMethodForProxyRequest.setRequestHeader(header);
-            }
-        }
-    }
-    
-    private void postFormParams(PostMethod httpMethodForProxyRequest, HttpServletRequest request)
-    {
-        Map<String, String[]> paramsMap = (Map<String, String[]>) request.getParameterMap();
-        List<NameValuePair> paramNameValuePairs = new ArrayList<NameValuePair>();
-        
-        for (String paramName : paramsMap.keySet())
-        {
-            String [] paramValues = paramsMap.get(paramName);
-            
-            for (String paramValue : paramValues)
-            {
-                NameValuePair nameValuePair = new NameValuePair(paramName, paramValue);
-                paramNameValuePairs.add(nameValuePair);
-            }
-        }
-        
-        httpMethodForProxyRequest.setRequestBody(paramNameValuePairs.toArray(new NameValuePair[] {}));
-    }
-    
-    private void postMultipartParams(PostMethod httpMethodForProxyRequest, HttpServletRequest request) throws IOException
-    {
-        DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();
-        
-        if (maxFileUploadSize > 0)
-        {
-            fileItemFactory.setSizeThreshold(maxFileUploadSize);
-        }
-        
-        if (fileUploadDir != null)
-        {
-            fileItemFactory.setRepository(fileUploadDir);
-        }
-        
-        ServletFileUpload fileUpload = new ServletFileUpload(fileItemFactory);
-        
-        try
-        {
-            List<FileItem> fileItems = (List<FileItem>) fileUpload.parseRequest(request);
-            Part [] parts = new Part[fileItems.size()];
-            int i = 0;
-            
-            for (FileItem fileItem : fileItems)
-            {
-                if (fileItem.isFormField())
-                {
-                    parts[i] = (new StringPart(fileItem.getFieldName(), fileItem.getString()));
-                }
-                else
-                {
-                    PartSource partSource = null;
-                    
-                    if (fileItem.isInMemory())
-                    {
-                        partSource = new ByteArrayPartSource(fileItem.getName(), fileItem.get());
-                    }
-                    else
-                    {
-                        partSource = new FilePartSource(fileItem.getFieldName(), ((DiskFileItem) fileItem).getStoreLocation());
-                    }
-                    
-                    parts[i] = (new FilePart(fileItem.getFieldName(), partSource));
-                }
-                
-                i++;
+                IOUtils.closeQuietly(out);
             }
-            
-            MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(parts, httpMethodForProxyRequest.getParams());
-            httpMethodForProxyRequest.setRequestEntity(multipartRequestEntity);
-            
-            // The current content-type header (received from the client) IS of
-            // type "multipart/form-data", but the content-type header also
-            // contains the chunk boundary string of the chunks. Currently, this
-            // header is using the boundary of the client request, since we
-            // blindly copied all headers from the client request to the proxy
-            // request. However, we are creating a new request with a new chunk
-            // boundary string, so it is necessary that we re-set the
-            // content-type string to reflect the new chunk boundary string
-            httpMethodForProxyRequest.setRequestHeader(CONTENT_TYPE_HEADER, multipartRequestEntity.getContentType());
-        }
-        catch (FileUploadException fileUploadException)
-        {
-            throw new IOException(fileUploadException.getLocalizedMessage());
         }
     }
     

Modified: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml?rev=818122&r1=818121&r2=818122&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml (original)
+++ portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml Wed Sep 23 14:42:24 2009
@@ -56,19 +56,33 @@
       <param-name>reverseproxy.urlmappings</param-name>
       <param-value>/WEB-INF/conf/reverseproxy-urlmappings.properties</param-value>
     </init-param>
-    <!-- You can set httpclient's HttpConnectionManagerParams properties by prefixing 'connection.property.'. -->
     <init-param>
-      <param-name>connection.property.maxTotalConnections</param-name>
+      <param-name>client.param.allowCircularRedirects</param-name>
+      <param-value>false</param-value>
+    </init-param>
+    <init-param>
+      <param-name>conn.manager.param.maxTotalConnections</param-name>
       <param-value>200</param-value>
     </init-param>
     <init-param>
-      <param-name>connection.property.defaultMaxConnectionsPerHost</param-name>
+      <param-name>conn.manager.param.timeout</param-name>
+      <param-value>10000</param-value>
+    </init-param>
+    <init-param>
+      <param-name>conn.per.route.param.defaultMaxPerRoute</param-name>
       <param-value>20</param-value>
     </init-param>
-    <!-- You can set max connection per host by appending the host uri after 'maxConnectionsPerHost.'. -->
     <init-param>
-      <param-name>connection.property.maxConnectionsPerHost.http://portals.apache.org/</param-name>
-      <param-value>40</param-value>
+      <param-name>conn.per.route.param.maxForRoutes</param-name>
+      <param-value>
+        {
+          "routes" : 
+          [
+            { "target" : { "hostname" : "portals.apache.org" }, "max" : 40 },
+            { "target" : { "hostname" : "www.apache.org" }, "max" : 20 }
+          ]
+        }
+      </param-value>
     </init-param>
     <load-on-startup>11</load-on-startup>
   </servlet>



Mime
View raw message