Skip to content

Commit 6866b1d

Browse files
author
Stephane Landelle
committed
Add getURI method on ProxyServer, close #253
1 parent 719fbe8 commit 6866b1d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

api/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
private boolean isBasic = true;
@@ -69,6 +73,7 @@ public ProxyServer(final Protocol protocol, final String host, final int port, S
6973
this.port = port;
7074
this.principal = principal;
7175
this.password = password;
76+
this.uri = AsyncHttpProviderUtils.createUri(toString());
7277
}
7378

7479
public ProxyServer(final String host, final int port, String principal, String password) {
@@ -116,6 +121,10 @@ public String getEncoding() {
116121
return encoding;
117122
}
118123

124+
public URI getURI() {
125+
return uri;
126+
}
127+
119128
public ProxyServer addNonProxyHost(String uri) {
120129
nonProxyHosts.add(uri);
121130
return this;
@@ -141,7 +150,7 @@ public String getNtlmDomain() {
141150

142151
@Override
143152
public String toString() {
144-
return String.format("%s://%s:%d", protocol.toString(), host, port);
153+
return protocol + "://" + host + ":" + port;
145154
}
146155
}
147156

0 commit comments

Comments
 (0)