Skip to content

Commit a89ef52

Browse files
committed
Default API Url updated in HttpClient builder
1 parent 1cd9a06 commit a89ef52

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/main/java/com/opentok/OpenTok.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ public OpenTok(int apiKey, String apiSecret) {
7171

7272
this.apiKey = apiKey;
7373
this.apiSecret = apiSecret;
74-
75-
HttpClient.Builder clientBuilder = new HttpClient.Builder(apiKey, apiSecret).apiUrl(DefaultApiUrl.DEFAULT_API_URI);
76-
77-
this.client = clientBuilder.build();
74+
this.client = new HttpClient.Builder(apiKey, apiSecret).build();
7875
}
7976

8077
private OpenTok(int apiKey, String apiSecret, HttpClient httpClient) {
@@ -525,8 +522,7 @@ public OpenTok build() {
525522
if (this.apiUrl != null) {
526523
clientBuilder.apiUrl(this.apiUrl);
527524
}
528-
if(this.proxy!=null)
529-
{
525+
if (this.proxy!=null) {
530526
clientBuilder.proxy(this.proxy);
531527
}
532528

src/main/java/com/opentok/constants/DefaultApiUrl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* OpenTok Java SDK
3+
* Copyright (C) 2016 TokBox, Inc.
4+
* http://www.tokbox.com
5+
*
6+
* Licensed under The MIT License (MIT). See LICENSE file for more information.
7+
*/
18
package com.opentok.constants;
29

310
public class DefaultApiUrl

src/main/java/com/opentok/util/HttpClient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.ning.http.client.filter.FilterException;
2626
import com.ning.http.client.filter.RequestFilter;
2727
import com.opentok.ArchiveProperties;
28+
import com.opentok.constants.DefaultApiUrl;
2829
import com.opentok.constants.Version;
2930
import com.opentok.exception.OpenTokException;
3031
import com.opentok.exception.RequestException;
@@ -311,9 +312,15 @@ public HttpClient build() {
311312
AsyncHttpClientConfig.Builder configBuilder = new AsyncHttpClientConfig.Builder()
312313
.setUserAgent("Opentok-Java-SDK/" + Version.VERSION + " JRE/" + System.getProperty("java.version"))
313314
.addRequestFilter(new PartnerAuthRequestFilter(this.apiKey, this.apiSecret));
315+
316+
if (this.apiUrl==null) {
317+
this.apiUrl=DefaultApiUrl.DEFAULT_API_URI;
318+
}
319+
314320
if (this.proxy != null) {
315321
configBuilder.setProxyServer(createProxyServer(this.proxy));
316322
}
323+
317324
this.config = configBuilder.build();
318325
// NOTE: not thread-safe, config could be modified by another thread here?
319326
HttpClient client = new HttpClient(this);

0 commit comments

Comments
 (0)