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 ib...@apache.org on 2004/01/22 15:15:41 UTC
cvs commit: jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib WebdavResource.java WebdavFile.java
ib 2004/01/22 06:15:41
Modified: webdavclient/commandline/src/java/org/apache/webdav/cmd Tag:
SLIDE_2_0_RELEASE_BRANCH Client.java
webdavclient/clientlib/src/java/org/apache/webdav/lib Tag:
SLIDE_2_0_RELEASE_BRANCH WebdavResource.java
WebdavFile.java
Log:
Fix broken https support, still a bug needs to be fixed in Commons HttpClient
Revision Changes Path
No revision
No revision
1.2.2.1 +17 -10 jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.java
Index: Client.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- Client.java 19 Jan 2004 09:30:01 -0000 1.2
+++ Client.java 22 Jan 2004 14:15:41 -0000 1.2.2.1
@@ -81,6 +81,8 @@
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpURL;
+import org.apache.commons.httpclient.HttpsURL;
+import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.util.QName;
import org.apache.webdav.lib.Ace;
@@ -300,7 +302,7 @@
try {
// Set up for processing WebDAV resources
- httpURL = new HttpURL(uri.toCharArray());
+ httpURL = uriToHttpURL(uri);
if (webdavResource == null) {
webdavResource = new WebdavResource(httpURL);
webdavResource.setDebug(debugLevel);
@@ -334,7 +336,7 @@
httpURL = null;
webdavResource = null;
}
- httpURL = new HttpURL(uri.toCharArray());
+ httpURL = uriToHttpURL(uri);
// It should be used like this way.
httpURL.setUserinfo(userName, password);
webdavResource = new WebdavResource(httpURL);
@@ -384,7 +386,7 @@
boolean succeeded = false;
if (param != null) {
if (!param.startsWith("/")) {
- httpURL = new HttpURL(param.toCharArray());
+ httpURL = uriToHttpURL(param);
Enumeration enum = null;
try {
// OPTIONS business logic
@@ -1208,11 +1210,11 @@
if ((properties!=null) && (properties.size()>0)) {
propertyValues =
- webdavResource.reportMethod(new HttpURL(path.toCharArray()), properties, 1);
+ webdavResource.reportMethod(uriToHttpURL(path), properties, 1);
}
else {
propertyValues =
- webdavResource.reportMethod(new HttpURL(path.toCharArray()), 1);
+ webdavResource.reportMethod(uriToHttpURL(path), 1);
}
if (propertyValues.hasMoreElements()){
@@ -1259,7 +1261,7 @@
out.println("expand-property Report of '" + path + "':");
Enumeration propertyValues =
- webdavResource.reportMethod(new HttpURL(path.toCharArray()), sQuery, 1);
+ webdavResource.reportMethod(uriToHttpURL(path), sQuery, 1);
if (propertyValues.hasMoreElements()){
while (propertyValues.hasMoreElements()){
out.println(displayXML(propertyValues.nextElement().toString(), 0));
@@ -1285,7 +1287,7 @@
out.println("Getting version-tree Report of '" + path + "':");
Enumeration propertyValues =
- webdavResource.reportMethod(new HttpURL(path.toCharArray()), properties, historyUris, 1);
+ webdavResource.reportMethod(uriToHttpURL(path), properties, historyUris, 1);
if (propertyValues.hasMoreElements()) {
while (propertyValues.hasMoreElements()) {
out.println(propertyValues.nextElement().toString());
@@ -1959,5 +1961,10 @@
}
}
return sResult;
+ }
+
+ private static HttpURL uriToHttpURL(String uri) throws URIException {
+ return uri.startsWith("https") ? new HttpsURL(uri.toCharArray())
+ : new HttpURL(uri.toCharArray());
}
}
No revision
No revision
1.3.2.1 +20 -9 jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- WebdavResource.java 21 Jan 2004 09:39:23 -0000 1.3
+++ WebdavResource.java 22 Jan 2004 14:15:41 -0000 1.3.2.1
@@ -963,8 +963,11 @@
if (!itself) {
String myURI = httpURL.getEscapedURI();
workingResource.setHttpURL(
- new HttpURL(myURI + (myURI.endsWith("/") ? "" : "/")
- + URIUtil.encodePath(displayName)),
+ httpURL instanceof HttpsURL
+ ? new HttpsURL(myURI + (myURI.endsWith("/") ? "" : "/")
+ + URIUtil.encodePath(displayName))
+ : new HttpURL(myURI + (myURI.endsWith("/") ? "" : "/")
+ + URIUtil.encodePath(displayName)),
NOACTION, defaultDepth);
workingResource.setExistence(true);
workingResource.setOverwrite(getOverwrite());
@@ -1191,7 +1194,9 @@
(HttpURL httpURL, String additionalPath, int action, int depth)
throws HttpException, IOException {
- setHttpURL(new HttpURL(httpURL, additionalPath), action, depth);
+ setHttpURL(httpURL instanceof HttpsURL
+ ? new HttpsURL((HttpsURL) httpURL, additionalPath)
+ : new HttpURL(httpURL, additionalPath), action, depth);
}
@@ -1212,7 +1217,10 @@
(HttpURL httpURL, String additionalPath, int action)
throws HttpException, IOException {
- setHttpURL(new HttpURL(httpURL, additionalPath), action, defaultDepth);
+ setHttpURL(httpURL instanceof HttpsURL
+ ? new HttpsURL((HttpsURL) httpURL, additionalPath)
+ : new HttpURL(httpURL, additionalPath),
+ action, defaultDepth);
}
@@ -1230,7 +1238,9 @@
public void setHttpURL(HttpURL httpURL, String additionalPath)
throws HttpException, IOException {
- setHttpURL(new HttpURL(httpURL, additionalPath),
+ setHttpURL(httpURL instanceof HttpsURL
+ ? new HttpsURL((HttpsURL) httpURL, additionalPath)
+ : new HttpURL(httpURL, additionalPath),
defaultAction, defaultDepth);
}
@@ -1290,7 +1300,8 @@
public HttpURL getHttpURLExceptForUserInfo()
throws URIException {
- return new HttpURL(httpURL.getRawURI());
+ return httpURL instanceof HttpsURL ? new HttpsURL(httpURL.getRawURI())
+ : new HttpURL(httpURL.getRawURI());
}
1.2.2.1 +7 -4 jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavFile.java
Index: WebdavFile.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavFile.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- WebdavFile.java 19 Jan 2004 09:30:01 -0000 1.2
+++ WebdavFile.java 22 Jan 2004 14:15:41 -0000 1.2.2.1
@@ -72,6 +72,7 @@
import java.util.Iterator;
import java.util.List;
import org.apache.commons.httpclient.HttpURL;
+import org.apache.commons.httpclient.HttpsURL;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.util.URIUtil;
@@ -118,7 +119,9 @@
* @param pass password
*/
public WebdavFile(URL url, String user, String pass) throws URIException {
- this(new HttpURL(user, pass, url.getHost(), url.getPort(), url.getPath()));
+ this(url.getProtocol().equals("https")
+ ? new HttpsURL(user, pass, url.getHost(), url.getPort(), url.getPath())
+ : new HttpURL(user, pass, url.getHost(), url.getPort(), url.getPath()));
}
/**
* @param parent parent name
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org