Skip to content

Commit 02b44e4

Browse files
Update TypeScript typings and remove responseSerializer.deserialize calls
Agent-Logs-Url: https://github.com/nativescript-community/https/sessions/cb3011ae-c8b8-4453-9b0e-af75b9bb74ce Co-authored-by: farfromrefug <655344+farfromrefug@users.noreply.github.com>
1 parent 1483106 commit 02b44e4

2 files changed

Lines changed: 51 additions & 33 deletions

File tree

packages/https/platforms/ios/src/AlamofireWrapper.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -927,14 +927,12 @@ public class AlamofireWrapper: NSObject {
927927
// Return with temp file path
928928
success(httpResponse, nil, tempFileURL.path)
929929
} catch {
930-
// Failed to write, just return data in memory
931-
let result = self.responseSerializer.deserialize(data: data, response: response.response)
932-
success(httpResponse, result, nil)
930+
// Failed to write, just return raw data in memory
931+
success(httpResponse, data, nil)
933932
}
934933
} else {
935-
// Small response or threshold not set, return data in memory
936-
let result = self.responseSerializer.deserialize(data: data, response: response.response)
937-
success(httpResponse, result, nil)
934+
// Small response or threshold not set, return raw data in memory
935+
success(httpResponse, data, nil)
938936
}
939937
} else {
940938
success(httpResponse, nil, nil)

src/https/typings/objc!AlamofireWrapper.d.ts

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,105 +12,125 @@ declare class AlamofireWrapper extends NSObject {
1212

1313
setDataTaskWillCacheResponseBlock(block: (session: NSURLSession, task: NSURLSessionDataTask, cacheResponse: NSCachedURLResponse) => NSCachedURLResponse): void;
1414

15-
// New clean API methods - updated to use NSURLSessionTask for flexibility
15+
// Request management
16+
cancelRequest(id: string): void;
17+
addInterceptor(interceptor: any): void;
18+
addEventMonitor(monitor: any): void;
19+
20+
// New clean API methods - using request IDs and NSHTTPURLResponse callbacks
1621
request(
1722
method: string,
1823
urlString: string,
1924
parameters: NSDictionary<string, any>,
2025
headers: NSDictionary<string, any>,
26+
requestId: string,
2127
uploadProgress: (progress: NSProgress) => void,
2228
downloadProgress: (progress: NSProgress) => void,
23-
success: (task: NSURLSessionTask, data: any) => void,
24-
failure: (task: NSURLSessionTask, error: NSError) => void
25-
): NSURLSessionTask;
29+
success: (response: NSHTTPURLResponse, data: any) => void,
30+
failure: (response: NSHTTPURLResponse, error: NSError) => void
31+
): void;
2632

2733
// Extended API with threading options
2834
requestWithThreading(
2935
method: string,
3036
urlString: string,
3137
parameters: NSDictionary<string, any>,
3238
headers: NSDictionary<string, any>,
39+
requestId: string,
3340
responseOnMainThread: NSNumber, // optional boolean
3441
progressOnMainThread: NSNumber, // optional boolean
3542
uploadProgress: (progress: NSProgress) => void,
3643
downloadProgress: (progress: NSProgress) => void,
37-
success: (task: NSURLSessionTask, data: any) => void,
38-
failure: (task: NSURLSessionTask, error: NSError) => void
39-
): NSURLSessionTask;
44+
success: (response: NSHTTPURLResponse, data: any) => void,
45+
failure: (response: NSHTTPURLResponse, error: NSError) => void
46+
): void;
4047

4148
uploadMultipart(
4249
urlString: string,
4350
headers: NSDictionary<string, any>,
51+
requestId: string,
4452
constructingBodyWithBlock: (formData: MultipartFormDataWrapper) => void,
4553
progress: (progress: NSProgress) => void,
46-
success: (task: NSURLSessionTask, data: any) => void,
47-
failure: (task: NSURLSessionTask, error: NSError) => void
48-
): NSURLSessionTask;
54+
success: (response: NSHTTPURLResponse, data: any) => void,
55+
failure: (response: NSHTTPURLResponse, error: NSError) => void
56+
): void;
4957

5058
// Extended API with threading options
5159
uploadMultipartWithThreading(
5260
urlString: string,
5361
headers: NSDictionary<string, any>,
62+
requestId: string,
5463
responseOnMainThread: NSNumber, // optional boolean
5564
progressOnMainThread: NSNumber, // optional boolean
5665
constructingBodyWithBlock: (formData: MultipartFormDataWrapper) => void,
5766
progress: (progress: NSProgress) => void,
58-
success: (task: NSURLSessionTask, data: any) => void,
59-
failure: (task: NSURLSessionTask, error: NSError) => void
60-
): NSURLSessionTask;
67+
success: (response: NSHTTPURLResponse, data: any) => void,
68+
failure: (response: NSHTTPURLResponse, error: NSError) => void
69+
): void;
6170

6271
uploadFile(
6372
request: NSMutableURLRequest,
6473
fileURL: NSURL,
74+
requestId: string,
6575
progress: (progress: NSProgress) => void,
66-
completionHandler: (response: NSURLResponse, responseObject: any, error: NSError) => void
67-
): NSURLSessionTask;
76+
success: (response: NSHTTPURLResponse, data: any) => void,
77+
failure: (response: NSHTTPURLResponse, error: NSError) => void
78+
): void;
6879

6980
uploadData(
7081
request: NSMutableURLRequest,
7182
bodyData: NSData,
83+
requestId: string,
7284
progress: (progress: NSProgress) => void,
73-
completionHandler: (response: NSURLResponse, responseObject: any, error: NSError) => void
74-
): NSURLSessionTask;
85+
success: (response: NSHTTPURLResponse, data: any) => void,
86+
failure: (response: NSHTTPURLResponse, error: NSError) => void
87+
): void;
7588

7689
downloadToTemp(
7790
method: string,
7891
urlString: string,
7992
parameters: NSDictionary<string, any>,
8093
headers: NSDictionary<string, any>,
94+
requestId: string,
8195
progress: (progress: NSProgress) => void,
82-
completionHandler: (response: NSURLResponse, tempFilePath: string, error: NSError) => void
83-
): NSURLSessionDownloadTask;
96+
success: (response: NSHTTPURLResponse, tempFilePath: string) => void,
97+
failure: (response: NSHTTPURLResponse, error: NSError) => void
98+
): void;
8499

85100
downloadToFile(
86101
urlString: string,
87102
destinationPath: string,
88103
headers: NSDictionary<string, any>,
104+
requestId: string,
89105
progress: (progress: NSProgress) => void,
90-
completionHandler: (response: NSURLResponse, filePath: string, error: NSError) => void
91-
): NSURLSessionDownloadTask;
106+
success: (response: NSHTTPURLResponse, filePath: string) => void,
107+
failure: (response: NSHTTPURLResponse, error: NSError) => void
108+
): void;
92109

93110
downloadToTempWithEarlyHeaders(
94111
method: string,
95112
urlString: string,
96113
parameters: NSDictionary<string, any>,
97114
headers: NSDictionary<string, any>,
115+
requestId: string,
98116
sizeThreshold: number,
99117
progress: (progress: NSProgress) => void,
100-
headersCallback: (response: NSURLResponse, contentLength: number) => void,
101-
completionHandler: (response: NSURLResponse, tempFilePath: string, error: NSError) => void
102-
): NSURLSessionDownloadTask;
118+
headersCallback: (response: NSHTTPURLResponse, contentLength: number) => void,
119+
success: (response: NSHTTPURLResponse, tempFilePath: string) => void,
120+
failure: (response: NSHTTPURLResponse, error: NSError) => void
121+
): void;
103122

104123
requestWithConditionalDownload(
105124
method: string,
106125
urlString: string,
107126
parameters: NSDictionary<string, any>,
108127
headers: NSDictionary<string, any>,
128+
requestId: string,
109129
sizeThreshold: number,
110130
progress: (progress: NSProgress) => void,
111-
success: (task: NSURLSessionTask, data: any, tempFilePath: string) => void,
112-
failure: (task: NSURLSessionTask, error: NSError) => void
113-
): NSURLSessionTask;
131+
success: (response: NSHTTPURLResponse, data: any, tempFilePath: string) => void,
132+
failure: (response: NSHTTPURLResponse, error: NSError) => void
133+
): void;
114134
}
115135

116136
declare class RequestSerializer extends NSObject {

0 commit comments

Comments
 (0)