You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bi...@apache.org on 2002/07/04 06:09:30 UTC
cvs commit: jakarta-tomcat/src/facade22/org/apache/tomcat/facade HttpServletResponseFacade.java
billbarker 2002/07/03 21:09:30
Modified: src/facade22/org/apache/tomcat/facade
HttpServletResponseFacade.java
Log:
Fix problem when the Context path contains a non-safe character.
As an added benefit, we get rid of the deprecated HttpUtils dependency. At some point, we should probably add a getRequestURL method to the core request to remove some of the repeated code.
Fix for bug #9111
Reported By: Alexander Lamm alaxander.lamm@livinglogic.de
Revision Changes Path
1.29 +24 -8 jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletResponseFacade.java
Index: HttpServletResponseFacade.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletResponseFacade.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- HttpServletResponseFacade.java 22 Mar 2002 02:54:34 -0000 1.28
+++ HttpServletResponseFacade.java 4 Jul 2002 04:09:30 -0000 1.29
@@ -358,7 +358,6 @@
} catch (MalformedURLException e) {
return (false);
}
-
// Does this URL match down to (and including) the context path?
if (!request.scheme().equalsIgnoreCase(url.getProtocol()))
return (false);
@@ -414,10 +413,7 @@
url = new URL(location);
} catch (MalformedURLException e1) {
Request request = response.getRequest();
- HttpServletRequestFacade reqF=(HttpServletRequestFacade)request.
- getFacade();
- String requrl =
- HttpUtils.getRequestURL(reqF).toString();
+ String requrl = getRequestURL(request);
try {
url = new URL(new URL(requrl), location);
} catch (MalformedURLException e2) {
@@ -427,6 +423,26 @@
return (url.toExternalForm());
}
+
+ /**
+ * Return the requested URL.
+ * Should be moved to util.
+ */
+ private String getRequestURL(Request req) {
+ StringBuffer sb = new StringBuffer();
+ int port = req.getServerPort();
+ String scheme = req.scheme().toString();
+ sb.append(scheme).append("://");
+ sb.append(req.serverName().toString());
+ if(("http".equalsIgnoreCase(scheme) && port != 80) ||
+ ("https".equalsIgnoreCase(scheme) && port != 443)) {
+ sb.append(':').append(port);
+ }
+ sb.append(req.requestURI().toString());
+ return sb.toString();
+ }
+
+
/**
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>