Skip to content

Commit b9889ae

Browse files
author
Stephane Landelle
committed
Add getURI method on ProxyServer, close AsyncHttpClient#253
1 parent c6f7fd9 commit b9889ae

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main/java/com/ning/http/client/ProxyServer.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
*/
1717
package com.ning.http.client;
1818

19+
import java.net.URI;
1920
import java.util.ArrayList;
2021
import java.util.Collections;
2122
import java.util.List;
2223

24+
import com.ning.http.util.AsyncHttpProviderUtils;
25+
2326
/**
2427
* Represents a proxy server.
2528
*/
@@ -44,13 +47,14 @@ public String toString() {
4447
}
4548
}
4649

47-
private String encoding = "UTF-8";
4850
private final List<String> nonProxyHosts = new ArrayList<String>();
4951
private final Protocol protocol;
5052
private final String host;
5153
private final String principal;
5254
private final String password;
53-
private int port;
55+
private final int port;
56+
private final URI uri;
57+
private String encoding = "UTF-8";
5458
private String ntlmDomain = System.getProperty("http.auth.ntlm.domain", "");
5559

5660
public ProxyServer(final Protocol protocol, final String host, final int port, String principal, String password) {
@@ -59,6 +63,7 @@ public ProxyServer(final Protocol protocol, final String host, final int port, S
5963
this.port = port;
6064
this.principal = principal;
6165
this.password = password;
66+
uri = AsyncHttpProviderUtils.createUri(toString());
6267
}
6368

6469
public ProxyServer(final String host, final int port, String principal, String password) {
@@ -97,6 +102,10 @@ public String getPassword() {
97102
return password;
98103
}
99104

105+
public URI getUri() {
106+
return uri;
107+
}
108+
100109
public ProxyServer setEncoding(String encoding) {
101110
this.encoding = encoding;
102111
return this;
@@ -131,7 +140,7 @@ public String getNtlmDomain() {
131140

132141
@Override
133142
public String toString() {
134-
return String.format("%s://%s:%d", protocol.toString(), host, port);
143+
return protocol + "://" + host + ":" + port;
135144
}
136145
}
137146

0 commit comments

Comments
 (0)