Index: examples/CustomHttpConnection.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/CustomHttpConnection.java,v
retrieving revision 1.3
diff -u -r1.3 CustomHttpConnection.java
--- examples/CustomHttpConnection.java 22 Apr 2003 18:11:01 -0000 1.3
+++ examples/CustomHttpConnection.java 18 Jul 2003 15:02:08 -0000
@@ -89,7 +89,7 @@
System.exit(1);
}
- URI uri = new URI(args[0].toCharArray()); // i like this constructor :)
+ URI uri = new URI(args[0], true);
String schema = uri.getScheme();
if ((schema == null) || (schema.equals("")))
Index: java/org/apache/commons/httpclient/HttpMethodBase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.169
diff -u -r1.169 HttpMethodBase.java
--- java/org/apache/commons/httpclient/HttpMethodBase.java 16 Jul 2003 20:48:27 -0000 1.169
+++ java/org/apache/commons/httpclient/HttpMethodBase.java 18 Jul 2003 15:02:11 -0000
@@ -266,7 +266,7 @@
if (uri == null || uri.equals("")) {
uri = "/";
}
- URI parsedURI = new URI(uri.toCharArray());
+ URI parsedURI = new URI(uri, true);
// only set the host if specified by the URI
if (parsedURI.isAbsoluteURI()) {
@@ -1120,7 +1120,7 @@
conn.getPort(),
this.getPath()
);
- redirectUri = new URI(location.toCharArray());
+ redirectUri = new URI(location, true);
if (redirectUri.isRelativeURI()) {
if (isStrictMode()) {
LOG.warn("Redirected location '" + location
Index: java/org/apache/commons/httpclient/URI.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URI.java,v
retrieving revision 1.38
diff -u -r1.38 URI.java
--- java/org/apache/commons/httpclient/URI.java 11 Jul 2003 21:55:09 -0000 1.38
+++ java/org/apache/commons/httpclient/URI.java 18 Jul 2003 15:02:15 -0000
@@ -154,6 +154,43 @@
protected URI() {
}
+ /**
+ * Construct a URI from a string with the given charset. The input string can
+ * be either in escaped or unescaped form.
+ *
+ * @param s URI character sequence
+ * @param escaped true if URI character sequence is in escaped form.
+ * false otherwise.
+ * @param charset the charset string to do escape encoding, if required
+ *
+ * @throws URIException If the URI cannot be created.
+ * @throws NullPointerException if input string is null
+ *
+ * @see #getProtocolCharset
+ */
+ public URI(String s, boolean escaped, String charset)
+ throws URIException, NullPointerException {
+ protocolCharset = charset;
+ parseUriReference(s, escaped);
+ }
+
+ /**
+ * Construct a URI from a string with the given charset. The input string can
+ * be either in escaped or unescaped form.
+ *
+ * @param s URI character sequence
+ * @param escaped true if URI character sequence is in escaped form.
+ * false otherwise.
+ *
+ * @throws URIException If the URI cannot be created.
+ * @throws NullPointerException if input string is null
+ *
+ * @see #getProtocolCharset
+ */
+ public URI(String s, boolean escaped)
+ throws URIException, NullPointerException {
+ parseUriReference(s, escaped);
+ }
/**
* Construct a URI as an escaped form of a character array with the given
@@ -164,6 +201,8 @@
* @throws URIException If the URI cannot be created.
* @throws NullPointerException if escaped is null
* @see #getProtocolCharset
+ *
+ * @deprecated Use #URI(String, boolean, String)
*/
public URI(char[] escaped, String charset)
throws URIException, NullPointerException {
@@ -181,6 +220,8 @@
* @throws URIException If the URI cannot be created.
* @throws NullPointerException if escaped is null
* @see #getDefaultProtocolCharset
+ *
+ * @deprecated Use #URI(String, boolean)
*/
public URI(char[] escaped)
throws URIException, NullPointerException {
@@ -196,6 +237,8 @@
* @param charset the charset string to do escape encoding
* @throws URIException If the URI cannot be created.
* @see #getProtocolCharset
+ *
+ * @deprecated Use #URI(String, boolean, String)
*/
public URI(String original, String charset) throws URIException {
protocolCharset = charset;
@@ -215,6 +258,8 @@
* It is one of absoluteURI and relativeURI.
* @throws URIException If the URI cannot be created.
* @see #getDefaultProtocolCharset
+ *
+ * @deprecated Use #URI(String, boolean)
*/
public URI(String original) throws URIException {
parseUriReference(original, false);
@@ -412,9 +457,26 @@
* @param base the base URI
* @param relative the relative URI string
* @throws URIException If the new URI cannot be created.
+ *
+ * @deprecated Use #URI(URI, String, boolean)
*/
public URI(URI base, String relative) throws URIException {
this(base, new URI(relative));
+ }
+
+
+ /**
+ * Construct a general URI with the given relative URI string.
+ *
+ * @param base the base URI
+ * @param relative the relative URI string
+ * @param escaped true if URI character sequence is in escaped form.
+ * false otherwise.
+ *
+ * @throws URIException If the new URI cannot be created.
+ */
+ public URI(URI base, String relative, boolean escaped) throws URIException {
+ this(base, new URI(relative, escaped));
}
Index: test/org/apache/commons/httpclient/TestURI.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestURI.java,v
retrieving revision 1.4
diff -u -r1.4 TestURI.java
--- test/org/apache/commons/httpclient/TestURI.java 19 Jun 2003 23:28:20 -0000 1.4
+++ test/org/apache/commons/httpclient/TestURI.java 18 Jul 2003 15:02:15 -0000
@@ -96,7 +96,7 @@
URI baseURI = null;
try {
- baseURI = new URI( "http://a/b/c/d;p?q" );
+ baseURI = new URI("http://a/b/c/d;p?q", false);
} catch ( URIException e ) {
fail( "unable to create base URI: " + e );
}
@@ -153,7 +153,7 @@
URI testURI = null;
try {
- testURI = new URI( baseURI, testRelativeURIs[i][0] );
+ testURI = new URI( baseURI, testRelativeURIs[i][0], false );
} catch ( URIException e ) {
e.printStackTrace();
fail(