Skip to content

Commit e89e07e

Browse files
Allow for variable timeout #49
1 parent ea44ec0 commit e89e07e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/https.android.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ let peer: Ipeer = {
1616
validatesDomainName: true
1717
};
1818

19+
let _timeout = 10;
20+
1921
export function enableSSLPinning(options: Https.HttpsSSLPinningOptions) {
2022
// console.log('options', options)
2123
if (!peer.host && !peer.certificate) {
@@ -70,10 +72,12 @@ function getClient(reload: boolean = false, timeout: number = 10): okhttp3.OkHtt
7072
// Client.connectionPool().evictAll()
7173
// Client = null
7274
// }
73-
if (Client && reload === false) {
75+
if (Client && reload === false && _timeout === timeout) {
7476
return Client;
7577
}
7678

79+
_timeout = timeout;
80+
7781
let client = new okhttp3.OkHttpClient.Builder();
7882
if (peer.enabled === true) {
7983
// console.log('peer', peer)
@@ -155,7 +159,7 @@ function getClient(reload: boolean = false, timeout: number = 10): okhttp3.OkHtt
155159
export function request(opts: Https.HttpsRequestOptions): Promise<Https.HttpsResponse> {
156160
return new Promise((resolve, reject) => {
157161
try {
158-
let client = getClient();
162+
let client = getClient(false, opts.timeout);
159163

160164
let request = new okhttp3.Request.Builder();
161165
request.url(opts.url);

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-https",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Secure HTTP client with SSL pinning for Nativescript - iOS/Android.",
55
"main": "https",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)