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 je...@apache.org on 2001/05/05 17:34:51 UTC
cvs commit: jakarta-slide/src/util/org/apache/util HttpURL.java GenericURI.java
jericho 01/05/05 08:34:51
Modified: src/webdav/client/src/org/apache/webdav/lib
WebdavSession.java
src/util/org/apache/util HttpURL.java GenericURI.java
Log:
- Change the order of endSession called in WebdavSession to get the http URL.
- Simplify the constructors and fix their bugs in HttpURL and GenericURI.
- Support minimum in HttpURL and GenericURI.
So, the default scheme for escaped URI is not attached automatically.
Revision Changes Path
1.7 +4 -4 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java
Index: WebdavSession.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WebdavSession.java 2001/05/05 07:00:48 1.6
+++ WebdavSession.java 2001/05/05 15:34:51 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v 1.6 2001/05/05 07:00:48 jericho Exp $
- * $Revision: 1.6 $
- * $Date: 2001/05/05 07:00:48 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v 1.7 2001/05/05 15:34:51 jericho Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/05/05 15:34:51 $
*
* ====================================================================
*
@@ -228,10 +228,10 @@
public synchronized void closeSession(HttpClient client)
throws IOException {
- client.endSession();
HttpURL httpURL =
new HttpURL(client.getUserName(), client.getPassword(),
client.getHost(), client.getPort());
+ client.endSession();
clientInfo.remove(httpURL.getAuthority());
// Remove the progress listener.
// webdavClient.getProgressUtil().addProgressListener(this);
1.2 +22 -28 jakarta-slide/src/util/org/apache/util/HttpURL.java
Index: HttpURL.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/util/org/apache/util/HttpURL.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpURL.java 2001/04/30 16:46:21 1.1
+++ HttpURL.java 2001/05/05 15:34:51 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/HttpURL.java,v 1.1 2001/04/30 16:46:21 jericho Exp $
- * $Revision: 1.1 $
- * $Date: 2001/04/30 16:46:21 $
+ * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/HttpURL.java,v 1.2 2001/05/05 15:34:51 jericho Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/05/05 15:34:51 $
*
* ====================================================================
*
@@ -80,10 +80,9 @@
/**
* This Constructor
*
- * @param httpURL The escaped URI string.
+ * @param httpURL The escaped http URL string.
*/
public HttpURL(String escapedHttpURL) {
-
super(escapedHttpURL);
setDefaultScheme(scheme);
setDefaultPort(port);
@@ -97,10 +96,7 @@
* @param path The path string.
*/
public HttpURL(String host, String path) {
-
- super(scheme, host, port, path);
- setDefaultScheme(scheme);
- setDefaultPort(port);
+ this(null, null, host, HttpURL.port, path, null);
}
@@ -112,10 +108,7 @@
* @param path The path string.
*/
public HttpURL(String host, int port, String path) {
-
- super(scheme, host, port, path);
- setDefaultScheme(scheme);
- setDefaultPort(port);
+ this(null, null, host, port, path, null);
}
@@ -127,9 +120,7 @@
* @param query The query string.
*/
public HttpURL(String host, String path, String query) {
- super(scheme, host, port, path, query);
- setDefaultScheme(scheme);
- setDefaultPort(port);
+ this(null, null, host, HttpURL.port, path, query);
}
@@ -142,10 +133,7 @@
* @param query The query string.
*/
public HttpURL(String host, int port, String path, String query) {
-
- super(scheme, host, port, path, query);
- setDefaultScheme(scheme);
- setDefaultPort(port);
+ this(null, null, host, port, path, query);
}
@@ -158,10 +146,7 @@
* @param port The port number.
*/
public HttpURL(String userName, String password, String host, int port) {
-
- super(scheme, userName, password, host, port, "/");
- setDefaultScheme(scheme);
- setDefaultPort(port);
+ this(userName, password, host, port, null, null);
}
@@ -176,10 +161,7 @@
*/
public HttpURL(String userName, String password, String host,
String path, String query) {
-
- super(scheme, userName, password, host, port, path, query);
- setDefaultScheme(scheme);
- setDefaultPort(port);
+ this(userName, password, host, HttpURL.port, path, query);
}
@@ -196,7 +178,19 @@
public HttpURL(String userName, String password, String host, int port,
String path, String query) {
- super(scheme, userName, password, host, port, path, query);
+ super
+ (URIUtil.escape(HttpURL.scheme, URIUtil.schemeReserved()) + "://" +
+ ((userName == null) ? "" :
+ URIUtil.escape(userName) + ((password == null) ? "" :
+ ":" + URIUtil.escape(password))
+ + "@") +
+ URIUtil.escape(host, URIUtil.hostReserved()) +
+ ((port == HttpURL.port || port == -1) ? "" : ":" + port) +
+ ((path == null || path.equals("")) ? "/" :
+ URIUtil.escape((!path.startsWith("/")) ?
+ "/" + path : path, URIUtil.pathReserved())) +
+ ((query == null || query.equals("")) ? "" :
+ "?" + URIUtil.escape(query, URIUtil.queryReserved())));
setDefaultScheme(scheme);
setDefaultPort(port);
}
1.3 +18 -40 jakarta-slide/src/util/org/apache/util/GenericURI.java
Index: GenericURI.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GenericURI.java 2001/05/02 08:11:27 1.2
+++ GenericURI.java 2001/05/05 15:34:51 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v 1.2 2001/05/02 08:11:27 jericho Exp $
- * $Revision: 1.2 $
- * $Date: 2001/05/02 08:11:27 $
+ * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v 1.3 2001/05/05 15:34:51 jericho Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/05/05 15:34:51 $
*
* ====================================================================
*
@@ -93,9 +93,7 @@
* @param URI The escaped URI string.
*/
public GenericURI(String escapedURI) {
-
- URI = (escapedURI.indexOf("://") > 0) ? escapedURI :
- getDefaultScheme() + "://" + escapedURI;
+ URI = escapedURI;
}
@@ -103,16 +101,11 @@
* This Constructor
*
* @param scheme The scheme string.
- * @param escapedAuthority The escaped authority string.
+ * @param host The host string.
* @param path The path string.
*/
- public GenericURI(String scheme, String escapedAuthority, String path) {
-
- if (!path.startsWith("/"))
- path = "/" + path;
- URI = URIUtil.escape(scheme, URIUtil.schemeReserved()) + "://" +
- URIUtil.escape(escapedAuthority, URIUtil.authorityReserved())+
- URIUtil.escape(path, URIUtil.pathReserved());
+ public GenericURI(String scheme, String host, String path) {
+ this(scheme, null, null, host, -1, null, null);
}
@@ -124,10 +117,7 @@
* @param port The port number.
*/
public GenericURI(String scheme, String host, int port) {
-
- URI = URIUtil.escape(scheme, URIUtil.schemeReserved()) + "://" +
- URIUtil.escape(host, URIUtil.hostReserved()) +
- ((port == defaultPort) ? "" : ":" + port) + "/";
+ this(scheme, null, null, host, port, null, null);
}
@@ -140,13 +130,7 @@
* @param path The path string.
*/
public GenericURI(String scheme, String host, int port, String path) {
-
- if (!path.startsWith("/"))
- path = "/" + path;
- URI = URIUtil.escape(scheme, URIUtil.schemeReserved()) + "://" +
- URIUtil.escape(host, URIUtil.hostReserved()) +
- ((port == defaultPort) ? "" : ":" + port) +
- URIUtil.escape(path, URIUtil.pathReserved());
+ this(scheme, null, null, host, port, path, null);
}
@@ -161,14 +145,7 @@
*/
public GenericURI(String scheme, String host, int port, String path,
String query) {
-
- if (!path.startsWith("/"))
- path = "/" + path;
- URI = URIUtil.escape(scheme, URIUtil.schemeReserved()) + "://" +
- URIUtil.escape(host, URIUtil.hostReserved()) +
- ((port == defaultPort) ? "" : ":" + port) +
- URIUtil.escape(path, URIUtil.pathReserved()) + "?" +
- URIUtil.escape(query, URIUtil.queryReserved());
+ this(scheme, null, null, host, port, path, query);
}
@@ -183,7 +160,7 @@
*/
public GenericURI(String scheme, String userName, String password,
String host, int port) {
- this(scheme, userName, password, host, port, "/", "");
+ this(scheme, userName, password, host, port, null, null);
}
@@ -199,7 +176,7 @@
*/
public GenericURI(String scheme, String userName, String password,
String host, int port, String path) {
- this(scheme, userName, password, host, port, path, "");
+ this(scheme, userName, password, host, port, path, null);
}
@@ -217,17 +194,18 @@
public GenericURI(String scheme, String userName, String password,
String host, int port, String path, String query) {
- if (!path.startsWith("/"))
- path = "/" + path;
URI = URIUtil.escape(scheme, URIUtil.schemeReserved()) + "://" +
((userName == null) ? "" :
URIUtil.escape(userName) + ((password == null) ? "" :
":" + URIUtil.escape(password))
+ "@") +
URIUtil.escape(host, URIUtil.hostReserved()) +
- ((port == defaultPort) ? "" : ":" + port) +
- URIUtil.escape(path, URIUtil.pathReserved()) + "?" +
- URIUtil.escape(query, URIUtil.queryReserved());
+ ((port == defaultPort || port == -1) ? "" : ":" + port) +
+ ((path == null || path.equals("")) ? "/" :
+ URIUtil.escape((!path.startsWith("/")) ?
+ "/" + path : path, URIUtil.pathReserved())) +
+ ((query == null || query.equals("")) ? "" :
+ "?" + URIUtil.escape(query, URIUtil.queryReserved()));
}