cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r421660 - /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
Date Thu, 13 Jul 2006 16:32:13 GMT
Author: cziegeler
Date: Thu Jul 13 09:32:13 2006
New Revision: 421660

URL: http://svn.apache.org/viewvc?rev=421660&view=rev
Log:
Add request wrapper

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java?rev=421660&r1=421659&r2=421660&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
Thu Jul 13 09:32:13 2006
@@ -18,17 +18,20 @@
 import java.io.IOException;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
 import javax.servlet.http.HttpServletResponse;
 
 /**
  * 
  * @version $Id$
+ * @since 2.2
  */
 public class RequestUtil {
 
     public static String getCompleteUri(HttpServletRequest request,
                                         HttpServletResponse response)
     throws IOException {
+        // We got it... Process the request
         String uri = request.getServletPath();
         if (uri == null) {
             uri = "";
@@ -58,9 +61,42 @@
             response.sendRedirect(response.encodeRedirectURL(prefix + "/"));
             return null;
         }
+
         if (uri.charAt(0) == '/') {
             uri = uri.substring(1);
         }
         return uri;
+    }
+
+    public static HttpServletRequest createRequestForUri(HttpServletRequest request, String
uri) {
+        return new HttpServletRequestImpl(request, uri);
+    }
+
+    /** TODO - we have to check the return values with the servlet spec! */
+    protected static final class HttpServletRequestImpl extends HttpServletRequestWrapper
{
+
+        final private String uri;
+
+        public HttpServletRequestImpl(HttpServletRequest request, String uri) {
+            super(request);
+            this.uri = uri;
+        }
+
+        public String getPathInfo() {
+            return this.uri;
+        }
+
+        public String getRequestURI() {
+            return this.uri;
+        }
+
+        public StringBuffer getRequestURL() {
+            return new StringBuffer(this.uri);
+        }
+
+        public String getServletPath() {
+            return null;
+        }
+
     }
 }



Mime
View raw message