juergen 02/04/12 05:27:03
Modified: src/webdav/server/org/apache/slide/webdav/method
WebdavMethod.java
Log:
Added method getAbsoluteURL() and some constants for HTTP protocol.
(ralf)
Revision Changes Path
1.48 +44 -3
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java
Index: WebdavMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- WebdavMethod.java 8 Apr 2002 12:43:00 -0000 1.47
+++ WebdavMethod.java 12 Apr 2002 12:27:03 -0000 1.48
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.47 2002/04/08 12:43:00 juergen Exp $
- * $Revision: 1.47 $
- * $Date: 2002/04/08 12:43:00 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.48 2002/04/12 12:27:03 juergen Exp $
+ * $Revision: 1.48 $
+ * $Date: 2002/04/12 12:27:03 $
*
* ====================================================================
*
@@ -112,6 +112,16 @@
// -------------------------------------------------------------- Constants
/**
+ * String constant for <code>http://</code>.
+ */
+ public static final String HTTP_PROTOCOL = "http://";
+
+ /**
+ * String constant for <code>HTTP/1.1</code>.
+ */
+ public static final String HTTP_VERSION = "HTTP/1.1";
+
+ /**
* String constant for <code>text/xml</code>.
*/
public static final String TEXT_XML = "text/xml";
@@ -595,6 +605,37 @@
}
}
+ /**
+ * Returns the absolute URL of the given <code>uri</code>, e.g.
+ * if the server is <code>aloha.com:80</code>, context path is
+ * <code>have</code> and the URI is <code>much/fun</code> the string
+ * <code>http://aloha:80/have/much/fun</code>.
+ *
+ * @param uri the URI for which to return the URL (may be
<code>null</code>).
+ *
+ * @return the absolute URL.
+ */
+ protected String getAbsoluteURL(String uri) {
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(HTTP_PROTOCOL);
+ buffer.append(req.getServerName());
+ buffer.append(":");
+ buffer.append(req.getServerPort());
+
+ if ( ! req.getContextPath().startsWith("/") ) {
+ buffer.append("/");
+ }
+ buffer.append(req.getContextPath());
+
+ if (uri != null) {
+ if ( !req.getContextPath().endsWith("/") && !uri.startsWith("/") ) {
+ buffer.append("/");
+ }
+ buffer.append(uri);
+ }
+ return buffer.toString();
+ }
// -------------------------------------------------------- Private Methods
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>