Skip to content

Commit 923d7e4

Browse files
committed
add Proxy support (via config's option) to internal JDKHttpClient (thanks to https://github.com/bjournaud)
1 parent 3b0c0e1 commit 923d7e4

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[SNAPSHOT]
2+
* add Proxy support (via config's option) to internal JDKHttpClient (thanks to https://github.com/bjournaud)
23

34
[7.0.0]
45
* Add Polar API (https://www.polar.com/) (thanks to https://github.com/vidi42)

scribejava-core/src/main/java/com/github/scribejava/core/httpclient/jdk/JDKHttpClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ public Response execute(String userAgent, Map<String, String> headers, Verb http
114114

115115
private Response doExecute(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl,
116116
BodyType bodyType, Object bodyContents) throws IOException {
117+
final URL url = new URL(completeUrl);
117118
final HttpURLConnection connection;
118119
if (config.getProxy() == null) {
119-
connection = (HttpURLConnection) new URL(completeUrl).openConnection();
120-
}else {
121-
connection = (HttpURLConnection) new URL(completeUrl).openConnection(config.getProxy());
120+
connection = (HttpURLConnection) url.openConnection();
121+
} else {
122+
connection = (HttpURLConnection) url.openConnection(config.getProxy());
122123
}
123124
connection.setInstanceFollowRedirects(config.isFollowRedirects());
124125
connection.setRequestMethod(httpVerb.name());

0 commit comments

Comments
 (0)