portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r1500734 - /portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
Date Mon, 08 Jul 2013 13:56:35 GMT
Author: woonsan
Date: Mon Jul  8 13:56:34 2013
New Revision: 1500734

URL: http://svn.apache.org/r1500734
Log:
APA-53: Applying Jeroen van Dun's patch to fix the case when redirect location is a relative
path, not an absolute URI, with polishing the patch (e.g, not using httpclient 3.x dependency
(we're using apache-hc 4.x)).

Modified:
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java

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=1500734&r1=1500733&r2=1500734&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
Mon Jul  8 13:56:34 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@ import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Enumeration;
@@ -95,131 +96,131 @@ import org.slf4j.LoggerFactory;
 
 /**
  * HTTP Reverse Proxy Service Implementation
- * 
+ *
  * @version $Id$
  */
 public class RewritableHttpReverseProxyServiceImpl implements HttpReverseProxyService
 {
-    
+
     private static Logger log = LoggerFactory.getLogger(RewritableHttpReverseProxyServiceImpl.class);
-    
+
     /**
      * Proxy path mapper provider
      */
     private HttpReverseProxyPathMapperProvider proxyPathMapperProvider;
-    
+
     /**
      * Default reverse proxy request context
      */
     private ReverseProxyRequestContextProvider defaultReverseProxyRequestContextProvider;
-    
+
     /**
      * Forced host header value
      */
     private String hostHeaderValue;
-    
+
     /**
      * forced local base url. e.g., "/webcontent/rproxy".
      */
     private String localBaseURL;
-    
+
     /**
      * SchemeRegistry
      */
     private SchemeRegistry schemeRegistry;
-    
+
     /**
      * The multithreaded connection manager for performance.
      */
     private ClientConnectionManager connectionManager;
-    
+
     /**
      * HTTP Connection Manager Parameters
      */
     private HttpParams connectionManagerParams;
-    
+
     /**
      * HTTP Client Parameters
      */
     private HttpParams clientParams;
-    
+
     /**
      * HTTP Route Planner
      */
     private HttpRoutePlanner httpRoutePlanner;
-    
+
     /**
      * URI Cleaner used to clean remote URIs before invoking HTTP Methods.
      */
     private URICleaner defaultURICleaner;
-    
+
     public RewritableHttpReverseProxyServiceImpl(HttpReverseProxyPathMapperProvider proxyPathMapperProvider,
ReverseProxyRequestContextProvider defaultReverseProxyRequestContextProvider)
     {
         this.proxyPathMapperProvider = proxyPathMapperProvider;
-        
+
         if (defaultReverseProxyRequestContextProvider != null)
         {
             this.defaultReverseProxyRequestContextProvider = defaultReverseProxyRequestContextProvider;
         }
     }
-    
+
     public void setHostHeaderValue(String hostHeaderValue)
     {
         this.hostHeaderValue = hostHeaderValue;
     }
-    
+
     public void setLocalBaseURL(String localBaseURL)
     {
         this.localBaseURL = localBaseURL;
     }
-    
+
     public void setClientParams(HttpParams clientParams)
     {
         this.clientParams = clientParams;
     }
-    
+
     public void setSchemeRegistry(SchemeRegistry schemeRegistry)
     {
         this.schemeRegistry = schemeRegistry;
     }
-    
+
     public void setConnectionManagerParams(HttpParams connectionManagerParams)
     {
         this.connectionManagerParams = connectionManagerParams;
     }
-    
+
     public void setHttpRoutePlanner(HttpRoutePlanner httpRoutePlanner)
     {
         this.httpRoutePlanner = httpRoutePlanner;
     }
-    
+
     public void setDefaultURICleaner(URICleaner defaultURICleaner)
     {
         this.defaultURICleaner = defaultURICleaner;
     }
-    
+
     public void initialize()
     {
         if (clientParams == null)
         {
             clientParams = new BasicHttpParams();
         }
-        
+
         if (connectionManagerParams == null)
         {
             connectionManagerParams = new BasicHttpParams();
         }
-        
+
         if (schemeRegistry == null)
         {
             schemeRegistry = new SchemeRegistry();
             schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(),
80));
             schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(),
443));
         }
-        
+
         connectionManager = new ThreadSafeClientConnManager(connectionManagerParams, schemeRegistry);
     }
-    
+
     public void destroy()
     {
         if (connectionManager != null)
@@ -227,38 +228,38 @@ public class RewritableHttpReverseProxyS
             connectionManager.shutdown();
         }
     }
-    
+
     public void invoke(HttpServletRequest request, HttpServletResponse response) throws HttpReverseProxyException,
IOException
     {
         // proxyPathMapper can be injected by using request attribute.
         HttpReverseProxyPathMapper proxyPathMapper = (HttpReverseProxyPathMapper) request.getAttribute(HttpReverseProxyConstants.PATH_MAPPER);
-        
+
         String localPathInfo = request.getPathInfo();
-        
+
         if (localPathInfo.indexOf('/', 1) == -1)
         {
             localPathInfo = localPathInfo + "/";
         }
-        
+
         if (proxyPathMapper == null)
         {
             proxyPathMapper = proxyPathMapperProvider.findMapper(localPathInfo);
         }
-        
+
         if (proxyPathMapper == null)
         {
             throw new HttpReverseProxyNotFoundException("Proxy configuration is not defined
for " + localPathInfo);
         }
-        
+
         if (proxyPathMapper.isSecured())
         {
             boolean allowed = false;
             Set<String> allowedRoles = proxyPathMapper.getAllowedRoles();
-            
+
             if (allowedRoles != null)
             {
                 ReverseProxyRequestContextProvider reverseProxyRequestContextProvider = findReverseProxyRequestContextProvider(request);
-                
+
                 for (String allowedRole : allowedRoles)
                 {
                     if (reverseProxyRequestContextProvider.isUserInRole(request, allowedRole))
@@ -268,7 +269,7 @@ public class RewritableHttpReverseProxyS
                     }
                 }
             }
-            
+
             if (!allowed)
             {
                 log.warn("The user is not in roles: " + allowedRoles);
@@ -276,7 +277,7 @@ public class RewritableHttpReverseProxyS
                 return;
             }
         }
-        
+
         if (hostHeaderValue == null)
         {
             if (request.getServerPort() == 80)
@@ -288,16 +289,16 @@ public class RewritableHttpReverseProxyS
                 hostHeaderValue = request.getServerName() + ":" + request.getServerPort();
             }
         }
-        
+
         String proxyTargetURL = proxyPathMapper.getRemoteURL(localPathInfo);
-        
+
         if (proxyTargetURL == null)
         {
             throw new HttpReverseProxyNotFoundException("Cannot translate the location path
info into remote URL. " + localPathInfo);
         }
-        
+
         String queryString = request.getQueryString();
-        
+
         if (queryString != null)
         {
             proxyTargetURL = new StringBuilder(proxyTargetURL.length() + 1 + queryString.length()).append(proxyTargetURL).append('?').append(queryString).toString();
@@ -305,41 +306,41 @@ public class RewritableHttpReverseProxyS
 
         final List<org.apache.http.cookie.Cookie> responseSetCookies = new ArrayList<org.apache.http.cookie.Cookie>();
         // create http client for each request...
-        DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, clientParams)

+        DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, clientParams)
         {
             @Override
-            protected CookieStore createCookieStore() 
+            protected CookieStore createCookieStore()
             {
-                return new BasicCookieStore() 
+                return new BasicCookieStore()
                 {
                     @Override
-                    public void addCookie(org.apache.http.cookie.Cookie cookie) 
+                    public void addCookie(org.apache.http.cookie.Cookie cookie)
                     {
                         responseSetCookies.add(cookie);
                     }
                 };
             }
         };
-        
+
         if (httpRoutePlanner != null)
         {
             httpClient.setRoutePlanner(httpRoutePlanner);
         }
-        
+
         // redirection should be adjusted with local host header...
         httpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
-        
+
         HttpRequestBase httpRequest = null;
-        
+
         String method = request.getMethod();
-        
+
         // Before invoking HTTP Methods, let's clean the remote target URI
         // in order to avoid invalid URI exception (e.g. space in the URI)
-        if (defaultURICleaner != null) 
+        if (defaultURICleaner != null)
         {
             proxyTargetURL = defaultURICleaner.clean(proxyTargetURL);
         }
-        
+
         if (HttpGet.METHOD_NAME.equals(method))
         {
             httpRequest = new HttpGet(proxyTargetURL);
@@ -352,7 +353,7 @@ public class RewritableHttpReverseProxyS
         {
             httpRequest = new HttpPost(proxyTargetURL);
             long contentLength = NumberUtils.toLong(request.getHeader(HTTP.CONTENT_LEN));
-            
+
             if (contentLength > 0L)
             {
                 HttpEntity entity = new InputStreamEntity(request.getInputStream(), contentLength);
@@ -362,9 +363,9 @@ public class RewritableHttpReverseProxyS
         else if (HttpPut.METHOD_NAME.equals(method))
         {
             httpRequest = new HttpPut(proxyTargetURL);
-            
+
             long contentLength = NumberUtils.toLong(request.getHeader(HTTP.CONTENT_LEN));
-            
+
             if (contentLength > 0L)
             {
                 HttpEntity entity = new InputStreamEntity(request.getInputStream(), contentLength);
@@ -387,13 +388,13 @@ public class RewritableHttpReverseProxyS
         {
             throw new HttpReverseProxyException("Unsupported method: " + method);
         }
-        
+
         // set sso credentials if available
         List<SSOSiteCredentials> credsList = getSSOSiteCredentials(proxyTargetURL,
httpClient, request);
         if (credsList != null && !credsList.isEmpty())
         {
             SSOSiteCredentials firstCreds = credsList.get(0);
-            
+
             if (firstCreds.isFormAuthentication() && StringUtils.equals(firstCreds.getBaseURL(),
proxyTargetURL))
             {
                 httpRequest = new HttpPost(proxyTargetURL);
@@ -412,27 +413,27 @@ public class RewritableHttpReverseProxyS
                 }
             }
         }
-        
+
         // pass most headers to proxy target...
-        for (Enumeration enumHeaderNames = request.getHeaderNames(); enumHeaderNames.hasMoreElements();
) 
+        for (Enumeration enumHeaderNames = request.getHeaderNames(); enumHeaderNames.hasMoreElements();
)
         {
             String headerName = (String) enumHeaderNames.nextElement();
-            
+
             if (StringUtils.equalsIgnoreCase(headerName, HTTP.CONTENT_LEN))
                 continue;
-            
+
             if (StringUtils.equalsIgnoreCase(headerName, HTTP.TARGET_HOST))
                 continue;
-            
+
             for (Enumeration enumHeaderValues = request.getHeaders(headerName); enumHeaderValues.hasMoreElements();
)
             {
                 String headerValue = (String) enumHeaderValues.nextElement();
                 httpRequest.addHeader(headerName, headerValue);
             }
         }
-        
+
         Map<String, String> defaultRequestHeaders = proxyPathMapper.getDefaultRequestHeaders();
-        
+
         if (defaultRequestHeaders != null)
         {
             for (Map.Entry<String, String> entry : defaultRequestHeaders.entrySet())
@@ -440,13 +441,13 @@ public class RewritableHttpReverseProxyS
                 httpRequest.setHeader(entry.getKey(), entry.getValue());
             }
         }
-        
+
         CookieStore cookieStore = httpClient.getCookieStore();
-        
+
         if (cookieStore != null)
         {
             Map<String, String> defaultRequestCookies = proxyPathMapper.getDefaultRequestCookies();
-            
+
             if (defaultRequestCookies != null)
             {
                 for (Map.Entry<String, String> entry : defaultRequestCookies.entrySet())
@@ -455,79 +456,94 @@ public class RewritableHttpReverseProxyS
                 }
             }
         }
-        
+
         HttpEntity httpEntity = null;
-        
+
         try
         {
             HttpResponse httpResponse = httpClient.execute(httpRequest);
             httpEntity = httpResponse.getEntity();
-            
+
             String rewriterContextPath = localBaseURL;
-            
-            if (rewriterContextPath == null) 
+
+            if (rewriterContextPath == null)
             {
                 rewriterContextPath = request.getContextPath() + request.getServletPath();
             }
-            
+
             int statusCode = httpResponse.getStatusLine().getStatusCode();
-            
+
             // Check if the proxy response is a redirect
             if (statusCode >= HttpServletResponse.SC_MULTIPLE_CHOICES /* 300 */
                 && statusCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */)
             {
                 String location = null;
                 Header locationHeader = httpResponse.getFirstHeader(HttpReverseProxyConstants.HTTP_HEADER_LOCATION);
-                
+
                 if (locationHeader != null)
                 {
                     location = locationHeader.getValue();
                 }
-                
+
                 if (location == null)
                 {
                     throw new HttpReverseProxyException("Recieved status code is " + statusCode
+ " but no " + HttpReverseProxyConstants.HTTP_HEADER_LOCATION + " header was found in the
response");
                 }
-                
+
+                // According to rfc2616, "Location" header value must be an absolute URI.
+                // However, in case it is not, prepend the host URI of the proxy target URL.
+                if (location.startsWith("/")) {
+                    URI targetURI = new URI(proxyTargetURL);
+                    String scheme = targetURI.getScheme();
+                    int port = targetURI.getPort();
+                    StringBuilder uriBuilder = new StringBuilder(40).append(targetURI.getScheme()).append("://").append(targetURI.getHost());
+
+                    if (port > 0 && ((port != 80 && "http".equals(scheme))
|| (port != 443 && "https".equals(scheme)))) {
+                        uriBuilder.append(':').append(port);
+                    }
+
+                    uriBuilder.append(location);
+                    location = uriBuilder.toString();
+                }
+
                 // Modify the redirect to go to this proxy servlet rather that the proxied
host
-                // FYI, according to rfc2616, "Location" header value must be an absolute
URI.
                 String localPath = proxyPathMapper.getLocalPath(location);
-                
+
                 // if the current proxy path mapper cannot map the remote location to local
path, then
                 // try to find out a possible path mapper instead one more...
                 if (localPath == null)
                 {
                     HttpReverseProxyPathMapper proxyPathMapperByLocation = proxyPathMapperProvider.findMapperByRemoteURL(location);
-                    
+
                     if (proxyPathMapperByLocation != null)
                     {
                         localPath = proxyPathMapperByLocation.getLocalPath(location);
                     }
                 }
-                
+
                 String redirectLocation = null;
-                
+
                 if (localPath == null)
                 {
                     if (log.isWarnEnabled())
                     {
                         log.warn("Cannot translate the redirect location to local path. {}",
location);
                     }
-                    
+
                     redirectLocation = location;
                 }
                 else
                 {
                     redirectLocation = rewriterContextPath + localPath;
                 }
-                
+
                 if (!responseSetCookies.isEmpty())
                 {
                     addResponseCookies(request, response, responseSetCookies, proxyPathMapper,
rewriterContextPath);
                 }
-                
+
                 response.sendRedirect(redirectLocation);
-                
+
                 return;
             }
             else if (statusCode == HttpServletResponse.SC_NOT_MODIFIED)
@@ -540,53 +556,53 @@ public class RewritableHttpReverseProxyS
                 // body because the file has not changed.
                 response.setIntHeader(HTTP.CONTENT_LEN, 0);
                 response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
-                
+
                 if (!responseSetCookies.isEmpty())
                 {
                     addResponseCookies(request, response, responseSetCookies, proxyPathMapper,
rewriterContextPath);
                 }
-                
+
                 return;
             }
             else
             {
                 // Pass the response code back to the client
                 response.setStatus(statusCode);
-                
+
                 if (httpEntity != null)
                 {
                     boolean rewritable = false;
                     Rewriter rewriter = null;
                     ParserAdaptor parserAdaptor = null;
-                    
+
                     RewriterController rewriterController = proxyPathMapperProvider.getRewriterController(proxyPathMapper);
-                    
+
                     if (rewriterController != null)
                     {
                         parserAdaptor = createParserAdaptor(rewriterController, httpEntity);
-                        
+
                         if (parserAdaptor != null)
                         {
                             rewriter = createRewriter(rewriterController, proxyPathMapper);
                             rewritable = (rewriter != null);
                         }
                     }
-                    
+
                     // Pass response headers back to the client
                     Header [] headerArrayResponse = httpResponse.getAllHeaders();
-                    
+
                     for (Header header : headerArrayResponse)
                     {
                         String headerName = header.getName();
-                        
+
                         if (rewritable && StringUtils.equalsIgnoreCase(headerName,
HTTP.CONTENT_LEN))
                             continue;
-                        
+
                         if (StringUtils.startsWithIgnoreCase(headerName, "Set-Cookie"))
                             continue;
-                        
+
                         String headerValue = header.getValue();
-                        
+
                         if (StringUtils.equalsIgnoreCase(headerName, HTTP.TARGET_HOST))
                         {
                             response.setHeader(headerName, hostHeaderValue);
@@ -596,12 +612,12 @@ public class RewritableHttpReverseProxyS
                             response.setHeader(headerName, headerValue);
                         }
                     }
-                    
+
                     if (!responseSetCookies.isEmpty())
                     {
                         addResponseCookies(request, response, responseSetCookies, proxyPathMapper,
rewriterContextPath);
                     }
-                    
+
                     // Send the content to the client
                     writeHttpEntityToClient(response, httpEntity, proxyPathMapper, rewriterContextPath,
localPathInfo, rewriter, parserAdaptor);
                 }
@@ -617,10 +633,10 @@ public class RewritableHttpReverseProxyS
             {
                 log.error("IOException occurred during execution for {} {}", proxyTargetURL,
e);
             }
-            
+
             httpRequest.abort();
             httpEntity = null;
-            
+
             throw e;
         }
         catch (Exception e)
@@ -633,10 +649,10 @@ public class RewritableHttpReverseProxyS
             {
                 log.error("Exception occurred during execution for {} {}", proxyTargetURL,
e);
             }
-            
+
             httpRequest.abort();
             httpEntity = null;
-            
+
             throw new HttpReverseProxyException(e);
         }
         finally
@@ -647,7 +663,7 @@ public class RewritableHttpReverseProxyS
             }
         }
     }
-    
+
     private void addResponseCookies(HttpServletRequest request, HttpServletResponse response,
List<org.apache.http.cookie.Cookie> responseSetCookies, HttpReverseProxyPathMapper proxyPathMapper,
String rewriterContextPath)
     {
         boolean isSecureRequest = request.isSecure();
@@ -656,9 +672,9 @@ public class RewritableHttpReverseProxyS
         boolean includesEmpty = (includes == null || includes.isEmpty());
         boolean excludesEmpty = (excludes == null || excludes.isEmpty());
         boolean allEmpty = (includesEmpty && excludesEmpty);
-        
+
         String rewrittenCookiePath = rewriterContextPath + proxyPathMapper.getLocalBasePath();
-        
+
         for (org.apache.http.cookie.Cookie cookie : responseSetCookies)
         {
             String cookieName = cookie.getName();
@@ -666,28 +682,28 @@ public class RewritableHttpReverseProxyS
             responseCookie.setVersion(cookie.getVersion());
             responseCookie.setComment(cookie.getComment());
             Date expireDate = cookie.getExpiryDate();
-            
+
             if (expireDate != null)
             {
                 int maxAgeSeconds = (int) ((expireDate.getTime() - System.currentTimeMillis())
/ 1000L);
                 responseCookie.setMaxAge(maxAgeSeconds);
             }
-            
+
             responseCookie.setSecure(isSecureRequest && cookie.isSecure());
             responseCookie.setVersion(cookie.getVersion());
-            
+
             if ((allEmpty) || (!includesEmpty && includes.contains(cookieName)) ||
(!excludesEmpty && !excludes.contains(cookieName)))
             {
                 responseCookie.setPath(rewrittenCookiePath);
             }
-            
+
             response.addCookie(responseCookie);
         }
     }
 
-    private void writeHttpEntityToClient(HttpServletResponse response, 
-                                         HttpEntity httpEntity, 
-                                         HttpReverseProxyPathMapper proxyPathMapper, 
+    private void writeHttpEntityToClient(HttpServletResponse response,
+                                         HttpEntity httpEntity,
+                                         HttpReverseProxyPathMapper proxyPathMapper,
                                          String rewriterContextPath,
                                          String localPathInfo,
                                          Rewriter rewriter,
@@ -697,17 +713,17 @@ public class RewritableHttpReverseProxyS
         Reader reader = null;
         OutputStream out = null;
         Writer writer = null;
-        
-        try 
+
+        try
         {
             in = httpEntity.getContent();
-            
+
             // According to javadoc of httpclient, getResponseBodyAsStream() can return null
             // if the response has no body.
             if (in != null)
             {
                 out = response.getOutputStream();
-                
+
                 if (rewriter == null || parserAdaptor == null)
                 {
                     IOUtils.copy(in, out);
@@ -717,21 +733,21 @@ public class RewritableHttpReverseProxyS
                 {
                     boolean gzipEncoded = false;
                     Header contentEncodingHeader = httpEntity.getContentEncoding();
-                    
+
                     if (contentEncodingHeader != null)
                     {
                         gzipEncoded = StringUtils.equalsIgnoreCase("gzip", contentEncodingHeader.getValue());
                     }
-                    
+
                     if (parserAdaptor instanceof ReverseProxyRewritingContextAware)
                     {
-                        ReverseProxyRewritingContext rewritingContext = 
+                        ReverseProxyRewritingContext rewritingContext =
                             new DefaultReverseProxyRewritingContext(proxyPathMapper, proxyPathMapperProvider,
rewriterContextPath);
                         ((ReverseProxyRewritingContextAware) parserAdaptor).setReverseProxyRewritingContext(rewritingContext);
                     }
-                    
+
                     String responseCharSet = EntityUtils.getContentCharSet(httpEntity);
-                    
+
                     if (responseCharSet != null)
                     {
                         reader = new InputStreamReader(gzipEncoded ? new GZIPInputStream(in)
: in, responseCharSet);
@@ -742,7 +758,7 @@ public class RewritableHttpReverseProxyS
                         reader = new InputStreamReader(gzipEncoded ? new GZIPInputStream(in)
: in);
                         writer = new OutputStreamWriter(gzipEncoded ? new GZIPOutputStream(out)
: out);
                     }
-                    
+
                     rewriter.setBaseUrl(rewriterContextPath + localPathInfo);
                     rewriter.rewrite(parserAdaptor, reader, writer);
                     writer.flush();
@@ -769,11 +785,11 @@ public class RewritableHttpReverseProxyS
             }
         }
     }
-    
+
     private Rewriter createRewriter(RewriterController rewriterController, HttpReverseProxyPathMapper
proxyPathMapper) throws Exception
     {
         Ruleset rewriterRuleset = proxyPathMapperProvider.getRewriterRuleset(proxyPathMapper);
-        
+
         if (rewriterRuleset == null)
         {
             return rewriterController.createRewriter();
@@ -783,17 +799,17 @@ public class RewritableHttpReverseProxyS
             return rewriterController.createRewriter(rewriterRuleset);
         }
     }
-    
+
     private ParserAdaptor createParserAdaptor(RewriterController rewriterController, HttpEntity
httpEntity) throws Exception
     {
         String contentType = null;
         Header contentTypeHeader = httpEntity.getContentType();
-        
+
         if (contentTypeHeader != null)
         {
             contentType = contentTypeHeader.getValue();
         }
-        
+
         if (contentType == null)
         {
             return null;
@@ -801,29 +817,29 @@ public class RewritableHttpReverseProxyS
 
         String mimeType = contentType;
         int offset = mimeType.indexOf(';');
-            
+
         if (offset > 0)
         {
             mimeType = mimeType.substring(0, offset).trim();
         }
-        
+
         return rewriterController.createParserAdaptor(mimeType);
     }
-    
+
     private List<SSOSiteCredentials> getSSOSiteCredentials(String siteURL, DefaultHttpClient
httpClient, HttpServletRequest request)
     {
         SSOSiteCredentialsProvider credsProvider = (SSOSiteCredentialsProvider) request.getAttribute(HttpReverseProxyConstants.SSO_SITE_CREDENTIALS_PROVIDER);
-        
+
         if (credsProvider == null)
         {
             HttpSession session = request.getSession(false);
-            
+
             if (session != null)
             {
                 credsProvider = (SSOSiteCredentialsProvider) session.getAttribute(HttpReverseProxyConstants.SSO_SITE_CREDENTIALS_PROVIDER);
             }
         }
-        
+
         if (credsProvider == null)
         {
             return null;
@@ -833,28 +849,28 @@ public class RewritableHttpReverseProxyS
             return credsProvider.getSSOCredentials(request, siteURL);
         }
     }
-    
+
     private ReverseProxyRequestContextProvider findReverseProxyRequestContextProvider(HttpServletRequest
request)
     {
         ReverseProxyRequestContextProvider reverseProxyRequestContextProvider = (ReverseProxyRequestContextProvider)
request.getAttribute(ReverseProxyRequestContextProvider.ROLE);
-        
+
         if (reverseProxyRequestContextProvider != null)
         {
             return reverseProxyRequestContextProvider;
         }
-        
+
         HttpSession session = request.getSession(false);
-        
+
         if (session != null)
         {
             reverseProxyRequestContextProvider = (ReverseProxyRequestContextProvider) session.getAttribute(ReverseProxyRequestContextProvider.ROLE);
-            
+
             if (reverseProxyRequestContextProvider != null)
             {
                 return reverseProxyRequestContextProvider;
             }
         }
-        
+
         return defaultReverseProxyRequestContextProvider;
     }
 }



Mime
View raw message