You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@apache.org on 2001/02/25 08:28:42 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods CopyMethod.java MoveMethod.java WebdavMethod.java WebdavMethodBase.java XMLResponseMethodBase.java
remm 01/02/24 23:28:42
Modified: src/webdav/client/src/org/apache/webdav/lib
WebdavClient.java
src/webdav/client/src/org/apache/webdav/lib/methods
CopyMethod.java MoveMethod.java WebdavMethod.java
WebdavMethodBase.java XMLResponseMethodBase.java
Log:
- Add switches to enable / disable URL encoding, and add ways to specify the
character encoding used. By default, it will use encoding, and UTF-8 will
be used for both encoding and decoding.
Revision Changes Path
1.24 +68 -5 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java
Index: WebdavClient.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- WebdavClient.java 2001/02/24 09:00:53 1.23
+++ WebdavClient.java 2001/02/25 07:28:42 1.24
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v 1.23 2001/02/24 09:00:53 jericho Exp $
- * $Revision: 1.23 $
- * $Date: 2001/02/24 09:00:53 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v 1.24 2001/02/25 07:28:42 remm Exp $
+ * $Revision: 1.24 $
+ * $Date: 2001/02/25 07:28:42 $
*
* ====================================================================
*
@@ -74,6 +74,7 @@
import java.net.UnknownHostException;
import java.net.URL;
import java.lang.reflect.Method;
+import org.apache.util.URLUtil;
import org.apache.webdav.lib.methods.WebdavMethod;
/**
@@ -184,6 +185,24 @@
protected int debug = 0;
+ /**
+ * URL encoding switch.
+ */
+ protected static boolean encodeURLs = true;
+
+
+ /**
+ * URL encoding charset.
+ */
+ protected static String URLEncodingCharset = "UTF8";
+
+
+ /**
+ * URL decoding charset.
+ */
+ protected static String URLDecodingCharset = "UTF8";
+
+
// ------------------------------------------------------------- Properties
@@ -251,6 +270,30 @@
}
+ /**
+ * Set the URL encoding flag.
+ */
+ public static void setEncodeURLs(boolean encodeURLs) {
+ WebdavClient.encodeURLs = encodeURLs;
+ }
+
+
+ /**
+ * Set URL encoding charset.
+ */
+ public static void setURLEncodingCharset(String URLEncodingCharset) {
+ WebdavClient.URLEncodingCharset = URLEncodingCharset;
+ }
+
+
+ /**
+ * Set URL decoding charset.
+ */
+ public static void setURLDecodingCharset(String URLDecodingCharset) {
+ WebdavClient.URLDecodingCharset = URLDecodingCharset;
+ }
+
+
// --------------------------------------------------------- Public Methods
@@ -456,6 +499,26 @@
}
+ /**
+ * URL encode.
+ */
+ public static String URLEncode(String url) {
+ if (encodeURLs) {
+ return URLUtil.URLEncode(url, URLEncodingCharset);
+ } else {
+ return url;
+ }
+ }
+
+
+ /**
+ * URL decode.
+ */
+ public static String URLDecode(String url) {
+ return URLUtil.URLDecode(url, URLDecodingCharset);
+ }
+
+
// ------------------------------------------------------ Protected Methods
@@ -464,8 +527,8 @@
try {
if (socket == null) {
if (debug > 0)
- System.out.println("Reopen connection : Host:" + sessionHost
- + " Port:" + sessionPort);
+ System.out.println("Reopen connection : Host:"
+ + sessionHost + " Port:" + sessionPort);
socket = new Socket(this.sessionHost, this.sessionPort);
}
input = socket.getInputStream();
1.7 +5 -5 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java
Index: CopyMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CopyMethod.java 2001/02/17 04:43:13 1.6
+++ CopyMethod.java 2001/02/25 07:28:42 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java,v 1.6 2001/02/17 04:43:13 remm Exp $
- * $Revision: 1.6 $
- * $Date: 2001/02/17 04:43:13 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java,v 1.7 2001/02/25 07:28:42 remm Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/02/25 07:28:42 $
*
* ====================================================================
*
@@ -63,9 +63,9 @@
package org.apache.webdav.lib.methods;
-import org.apache.util.URLUtil;
import org.apache.webdav.lib.State;
import org.apache.webdav.lib.Header;
+import org.apache.webdav.lib.WebdavClient;
/**
* COPY Method.
@@ -199,7 +199,7 @@
super.generateHeaders(host, state);
String absoluteDestination = "http://" + host
- + URLUtil.URLEncode(destination, "UTF8");
+ + WebdavClient.URLEncode(destination);
setHeader("Destination", absoluteDestination);
if (!isOverwrite())
1.7 +7 -33 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java
Index: MoveMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MoveMethod.java 2001/02/17 04:43:13 1.6
+++ MoveMethod.java 2001/02/25 07:28:42 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java,v 1.6 2001/02/17 04:43:13 remm Exp $
- * $Revision: 1.6 $
- * $Date: 2001/02/17 04:43:13 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java,v 1.7 2001/02/25 07:28:42 remm Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/02/25 07:28:42 $
*
* ====================================================================
*
@@ -63,21 +63,17 @@
package org.apache.webdav.lib.methods;
-import java.io.*;
-import java.util.*;
-import org.apache.util.URLUtil;
import org.apache.webdav.lib.State;
import org.apache.webdav.lib.Header;
-import org.apache.webdav.lib.WebdavStatus;
+import org.apache.webdav.lib.WebdavClient;
-
/**
* MOVE Method.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
*/
public class MoveMethod
- extends WebdavMethodBase {
+ extends XMLResponseMethodBase {
// ----------------------------------------------------------- Constructors
@@ -190,6 +186,7 @@
// --------------------------------------------------- WebdavMethod Methods
+
/**
* Generate additional headers needed by the request.
*
@@ -201,34 +198,11 @@
super.generateHeaders(host, state);
String absoluteDestination = "http://" + host
- + URLUtil.URLEncode(destination, "UTF8");
+ + WebdavClient.URLEncode(destination);
setHeader("Destination", absoluteDestination);
if (!isOverwrite())
setHeader("Overwrite", "F");
-
- }
-
-
- /**
- * Generate the query body.
- *
- * @return String query
- */
- public String generateQuery() {
- return null;
- }
-
-
- /**
- * Parse response.
- *
- * @param is Input stream
- */
- public void parseResponse(InputStream is)
- throws IOException {
-
- // Parse the 207 error report
}
1.7 +8 -5 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethod.java
Index: WebdavMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethod.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WebdavMethod.java 2001/02/20 07:02:17 1.6
+++ WebdavMethod.java 2001/02/25 07:28:42 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethod.java,v 1.6 2001/02/20 07:02:17 remm Exp $
- * $Revision: 1.6 $
- * $Date: 2001/02/20 07:02:17 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethod.java,v 1.7 2001/02/25 07:28:42 remm Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/02/25 07:28:42 $
*
* ====================================================================
*
@@ -63,8 +63,11 @@
package org.apache.webdav.lib.methods;
-import java.io.*;
-import java.util.*;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Hashtable;
import org.apache.webdav.lib.State;
import org.apache.webdav.lib.Header;
import org.apache.webdav.lib.WebdavException;
1.13 +10 -7 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java
Index: WebdavMethodBase.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WebdavMethodBase.java 2001/02/20 07:02:17 1.12
+++ WebdavMethodBase.java 2001/02/25 07:28:42 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v 1.12 2001/02/20 07:02:17 remm Exp $
- * $Revision: 1.12 $
- * $Date: 2001/02/20 07:02:17 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v 1.13 2001/02/25 07:28:42 remm Exp $
+ * $Revision: 1.13 $
+ * $Date: 2001/02/25 07:28:42 $
*
* ====================================================================
*
@@ -63,9 +63,12 @@
package org.apache.webdav.lib.methods;
-import java.io.*;
-import java.util.*;
-import org.apache.util.URLUtil;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.Hashtable;
import org.apache.webdav.lib.State;
import org.apache.webdav.lib.Cookie;
import org.apache.webdav.lib.Header;
@@ -481,7 +484,7 @@
*/
public final String generateRequestLine() {
- return (getName() + " " + URLUtil.URLEncode(path, "UTF8") + " "
+ return (getName() + " " + WebdavClient.URLEncode(path) + " "
+ PROTOCOL + "\r\n");
}
1.8 +3 -3 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java
Index: XMLResponseMethodBase.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XMLResponseMethodBase.java 2001/02/15 17:40:20 1.7
+++ XMLResponseMethodBase.java 2001/02/25 07:28:42 1.8
@@ -81,11 +81,11 @@
import org.apache.webdav.lib.Property;
import org.apache.webdav.lib.WebdavException;
import org.apache.webdav.lib.WebdavStatus;
+import org.apache.webdav.lib.WebdavClient;
import org.apache.webdav.lib.properties.GetLastModifiedProperty;
import org.apache.webdav.lib.properties.ResourceTypeProperty;
-import org.apache.util.URLUtil;
import org.apache.util.DOMUtils;
import org.apache.util.DOMWriter;
@@ -366,7 +366,7 @@
public String getHref() {
Element href = getFirstElement("DAV:", "href");
if (href != null) {
- return URLUtil.URLDecode(DOMUtils.getTextValue(href));
+ return WebdavClient.URLDecode(DOMUtils.getTextValue(href));
} else {
return "";
}
@@ -376,7 +376,7 @@
NodeList list = this.node.getChildNodes();
Element result = null;
for (int i = 0;
- result == null && list != null && i < list.getLength(); i++ ) {
+ result == null && list != null && i < list.getLength(); i++) {
try {
Element child = (Element) list.item(i);