Index: /home/oleg/src/apache.org/jakarta-commons/httpclient-trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java =================================================================== --- /home/oleg/src/apache.org/jakarta-commons/httpclient-trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java (revision 154830) +++ /home/oleg/src/apache.org/jakarta-commons/httpclient-trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java (working copy) @@ -242,32 +242,23 @@ * @see org.apache.commons.httpclient.HttpMethod#getURI() */ public URI getURI() throws URIException { - - if (this.httphost == null) { - // just use a relative URI, the host hasn't been set - URI tmpUri = new URI(null, null, path, null, null); - tmpUri.setEscapedQuery(queryString); - return tmpUri; - } else { - - // we only want to include the port if it's not the default + StringBuffer buffer = new StringBuffer(); + if (this.httphost != null) { + buffer.append(this.httphost.getProtocol().getScheme()); + buffer.append("://"); + buffer.append(this.httphost.getHostName()); int port = this.httphost.getPort(); - if (port == this.httphost.getProtocol().getDefaultPort()) { - port = -1; + if (port != -1 && port != this.httphost.getProtocol().getDefaultPort()) { + buffer.append(":"); + buffer.append(port); } - URI tmpUri = new URI( - this.httphost.getProtocol().getScheme(), - null, - this.httphost.getHostName(), - port, - path, - null // to set an escaped form - ); - tmpUri.setEscapedQuery(queryString); - return tmpUri; - } - + buffer.append(this.path); + if (this.queryString != null) { + buffer.append('?'); + buffer.append(this.queryString); + } + return new URI(buffer.toString(), true); } /**