You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2003/07/22 20:17:49 UTC
cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethod.java HttpMethodBase.java
olegk 2003/07/22 11:17:49
Modified: httpclient/src/java/org/apache/commons/httpclient
HttpMethod.java HttpMethodBase.java
Log:
Bug fix #17947 (Need setURI() methods in HttpMethod interface)
Contributed by Oleg Kalnichevski
Reviewed by Laura Werner
Revision Changes Path
1.24 +13 -4 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java
Index: HttpMethod.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- HttpMethod.java 28 Jan 2003 04:40:20 -0000 1.23
+++ HttpMethod.java 22 Jul 2003 18:17:48 -0000 1.24
@@ -126,6 +126,15 @@
URI getURI() throws URIException;
/**
+ * Sets the URI for this method.
+ *
+ * @param uri URI to be set
+ *
+ * @throws URIException if a URI cannot be set
+ */
+ void setURI(URI uri) throws URIException;
+
+ /**
* <p>Turns strict mode on or off. In strict mode (the default) we
* following the letter of RFC 2616, the Http 1.1 specification. If strict
* mode is turned off we attempt to violate the specification in the same
1.172 +34 -24 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Index: HttpMethodBase.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -r1.171 -r1.172
--- HttpMethodBase.java 22 Jul 2003 18:10:22 -0000 1.171
+++ HttpMethodBase.java 22 Jul 2003 18:17:48 -0000 1.172
@@ -267,26 +267,7 @@
if (uri == null || uri.equals("")) {
uri = "/";
}
- URI parsedURI = new URI(uri, true);
-
- // only set the host if specified by the URI
- if (parsedURI.isAbsoluteURI()) {
- hostConfiguration = new HostConfiguration();
- hostConfiguration.setHost(
- parsedURI.getHost(),
- parsedURI.getPort(),
- parsedURI.getScheme()
- );
- }
-
- // set the path, defaulting to root
- setPath(
- parsedURI.getPath() == null
- ? "/"
- : parsedURI.getEscapedPath()
- );
- setQueryString(parsedURI.getEscapedQuery());
-
+ setURI(new URI(uri, true));
} catch (URIException e) {
throw new IllegalArgumentException("Invalid uri '"
+ uri + "': " + e.getMessage()
@@ -338,6 +319,35 @@
}
+ }
+
+ /**
+ * Sets the URI for this method.
+ *
+ * @param uri URI to be set
+ *
+ * @throws URIException if a URI cannot be set
+ */
+ public void setURI(URI uri) throws URIException {
+ // only set the host if specified by the URI
+ if (uri.isAbsoluteURI()) {
+ if (this.hostConfiguration == null) {
+ this.hostConfiguration = new HostConfiguration();
+ }
+ this.hostConfiguration.setHost(
+ uri.getHost(),
+ uri.getPort(),
+ uri.getScheme()
+ );
+ }
+
+ // set the path, defaulting to root
+ setPath(
+ uri.getPath() == null
+ ? "/"
+ : uri.getEscapedPath()
+ );
+ setQueryString(uri.getEscapedQuery());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org