Skip to content

Commit a232425

Browse files
committed
fix: new getManager() method
1 parent dbfcc16 commit a232425

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/https/request.android.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@ interface Ipeer {
1313
certificate?: string;
1414
x509Certificate?: java.security.cert.Certificate;
1515
}
16-
function wrapJavaException(ex) {
17-
if (ex instanceof java.lang.Exception) {
18-
const err = new Error(ex.toString());
19-
err['nativeException'] = ex;
20-
//@ts-ignore
21-
err['stackTrace'] = com.tns.NativeScriptException.getStackTraceAsString(ex);
22-
return err;
23-
}
24-
return ex;
25-
}
16+
2617
const peer: Ipeer = {
2718
enabled: false,
2819
allowInvalidCertificates: false,
@@ -57,6 +48,10 @@ export function removeCachedResponse(url: string) {
5748
}
5849
}
5950

51+
export function getManager() {
52+
return getClient({}, false);
53+
}
54+
6055
// TODO: rewrite this to not have to handle
6156
// every single property
6257
let _timeout = 10;

src/https/request.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { File, HttpRequestOptions, ImageSource } from '@nativescript/core';
22
import * as Https from './request.common';
33

4+
export function getManager(): any; // okhttp3.OkHttpClient or AFHTTPSessionManager
5+
46
export interface HttpsSSLPinningOptions {
57
host: string;
68
certificate: string;

src/https/request.ios.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ policies.def.validatesDomainName = false;
3939
const configuration = NSURLSessionConfiguration.defaultSessionConfiguration;
4040
let manager = AFHTTPSessionManager.alloc().initWithSessionConfiguration(configuration);
4141

42+
export function getManager(): AFHTTPSessionManager {
43+
return manager;
44+
}
45+
4246
export function enableSSLPinning(options: HttpsSSLPinningOptions) {
4347
const url = NSURL.URLWithString(options.host);
4448
manager = AFHTTPSessionManager.alloc().initWithSessionConfiguration(configuration).initWithBaseURL(url);

0 commit comments

Comments
 (0)