Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit c174a85

Browse files
author
Zelle97
authored
Merge pull request #19 from Sybit-Education/develop
Proxy Fix
2 parents f2edf9b + 4672fff commit c174a85

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/main/java/com/sybit/airtable/Airtable.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,15 @@ public Airtable configure(Configuration config, ObjectMapper objectMapper) throw
179179
* @param proxy
180180
*/
181181
public void setProxy(String proxy) {
182-
if (proxy != null && !proxy.isEmpty() && !proxy.equals(" ")) {
182+
183+
if (proxy == null) {
184+
this.config.setProxy(proxy);
185+
Unirest.setProxy(null);
186+
} else {
183187
this.config.setProxy(proxy);
188+
Unirest.setProxy(HttpHost.create(this.config.getProxy()));
184189
}
190+
185191
}
186192

187193
/**
@@ -200,18 +206,22 @@ private void configureProxy(String endpointUrl) {
200206
&& (endpointUrl.contains("127.0.0.1")
201207
|| endpointUrl.contains("localhost"))) {
202208
LOG.info("Use Proxy: ignored for 'localhost' ann '127.0.0.1'");
203-
this.config.setProxy(null);
209+
setProxy(null);
204210
} else if (httpsProxy != null
205211
&& (endpointUrl.contains("https"))) {
206212
LOG.info("Use Proxy: Environment variable 'https_proxy' found and used: " + httpsProxy);
207-
this.config.setProxy(httpProxy);
213+
setProxy(httpProxy);
208214
} else if (httpProxy != null
209215
&& (endpointUrl.contains("http"))) {
210216
LOG.info("Use Proxy: Environment variable 'http_proxy' found and used: " + httpProxy);
211-
this.config.setProxy(httpsProxy);
217+
setProxy(httpsProxy);
212218
} else {
213-
this.config.setProxy(null);
219+
setProxy(null);
214220
}
221+
} else if ((endpointUrl.contains("127.0.0.1")
222+
|| endpointUrl.contains("localhost"))) {
223+
LOG.info("Use Proxy: ignored for 'localhost' ann '127.0.0.1'");
224+
setProxy(null);
215225
}
216226
}
217227

src/test/java/com/sybit/airtable/BaseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class BaseTest {
2323
@Before
2424
public void before() throws AirtableException{
2525

26-
this.airtable = new Airtable().configure(new Configuration("123","url",null));
26+
this.airtable = new Airtable().configure(new Configuration("123","http://localhost",null));
2727

2828

2929
}

src/test/java/com/sybit/airtable/TableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class TableTest {
2323
@Before
2424
public void before() throws AirtableException{
2525

26-
Airtable airtable = new Airtable().configure(new Configuration("123","url",null));
26+
Airtable airtable = new Airtable().configure(new Configuration("123","https://url",null));
2727
this.base = new Base("base", airtable);
2828

2929
}

0 commit comments

Comments
 (0)