Index: D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HostConfiguration.java
===================================================================
--- D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HostConfiguration.java (revision 387242)
+++ D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HostConfiguration.java (working copy)
@@ -300,7 +300,8 @@
*/
public synchronized void setHost(final URI uri) {
try {
- setHost(uri.getHost(), uri.getPort(), uri.getScheme());
+ // setHost(uri.getHost(), uri.getPort(), uri.getScheme());
+ this.host = new HttpHost(uri);
} catch (URIException e) {
throw new IllegalArgumentException(e.toString());
}
Index: D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
===================================================================
--- D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HttpMethodBase.java (revision 387242)
+++ D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HttpMethodBase.java (working copy)
@@ -246,7 +246,7 @@
if (this.httphost != null) {
buffer.append(this.httphost.getProtocol().getScheme());
buffer.append("://");
- buffer.append(this.httphost.getHostName());
+ buffer.append(this.httphost.getAuthority()==null?this.httphost.getHostName():this.httphost.getAuthority());
int port = this.httphost.getPort();
if (port != -1 && port != this.httphost.getProtocol().getDefaultPort()) {
buffer.append(":");
Index: D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HttpHost.java
===================================================================
--- D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HttpHost.java (revision 387242)
+++ D:/Dev/HttpClient/src/java/org/apache/commons/httpclient/HttpHost.java (working copy)
@@ -54,6 +54,8 @@
/** The protocol */
private Protocol protocol = null;
+ private String authority = null;
+
/**
* Constructor for HttpHost.
*
@@ -62,6 +64,18 @@
* @param protocol the protocol. Value null can be used to set default protocol
*/
public HttpHost(final String hostname, int port, final Protocol protocol) {
+ this(hostname, port, protocol, null);
+ }
+
+ /**
+ * Constructor for HttpHost.
+ *
+ * @param hostname the hostname (IP or DNS name). Can be null.
+ * @param port the port. Value -1 can be used to set default protocol port
+ * @param protocol the protocol. Value null can be used to set default protocol
+ * @param authority the authority.
+ */
+ public HttpHost(final String hostname, int port, final Protocol protocol, String authority ) {
super();
if (hostname == null) {
throw new IllegalArgumentException("Host name may not be null");
@@ -71,6 +85,7 @@
}
this.hostname = hostname;
this.protocol = protocol;
+ this.authority = authority;
if (port >= 0) {
this.port = port;
} else {
@@ -102,8 +117,8 @@
*
* @param uri the URI.
*/
- public HttpHost(final URI uri) throws URIException {
- this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
+ public HttpHost(final URI uri) throws URIException {
+ this(uri.getHost() , uri.getPort(), Protocol.getProtocol(uri.getScheme()), uri.getAuthority() );
}
/**
@@ -131,7 +146,7 @@
* @return the host name (IP or DNS name), or null if not set
*/
public String getHostName() {
- return this.hostname;
+ return this.hostname;
}
/**
@@ -152,6 +167,13 @@
}
/**
+ * @return Returns the authority.
+ */
+ public String getAuthority() {
+ return this.authority;
+ }
+
+ /**
* Return the host uri.
*
* @return The host uri.