Skip to content

Commit 3b0c0e1

Browse files
committed
Merge branch 'master' of https://github.com/bjournaud/scribejava into bjournaud-master
2 parents 6007a9e + 3f1cd63 commit 3b0c0e1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +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 HttpURLConnection connection = (HttpURLConnection) new URL(completeUrl).openConnection();
117+
final HttpURLConnection connection;
118+
if (config.getProxy() == null) {
119+
connection = (HttpURLConnection) new URL(completeUrl).openConnection();
120+
}else {
121+
connection = (HttpURLConnection) new URL(completeUrl).openConnection(config.getProxy());
122+
}
118123
connection.setInstanceFollowRedirects(config.isFollowRedirects());
119124
connection.setRequestMethod(httpVerb.name());
120125
if (config.getConnectTimeout() != null) {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.github.scribejava.core.httpclient.jdk;
22

3+
import java.net.Proxy;
4+
35
import com.github.scribejava.core.httpclient.HttpClientConfig;
46

57
public class JDKHttpClientConfig implements HttpClientConfig {
68

79
private Integer connectTimeout;
810
private Integer readTimeout;
911
private boolean followRedirects = true;
12+
private Proxy proxy;
1013

1114
@Override
1215
public JDKHttpClientConfig createDefaultConfig() {
@@ -37,6 +40,14 @@ public boolean isFollowRedirects() {
3740
return followRedirects;
3841
}
3942

43+
public void setProxy(Proxy proxy) {
44+
this.proxy = proxy;
45+
}
46+
47+
public Proxy getProxy() {
48+
return proxy;
49+
}
50+
4051
/**
4152
* Sets whether the underlying Http Connection follows redirects or not.
4253
*

0 commit comments

Comments
 (0)