Skip to content

Commit b160f13

Browse files
authoredJan 25, 2025
feat(background-http): add request timeout option for iOS (#607)
1 parent 92f2e5d commit b160f13

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed
 

Diff for: ‎packages/background-http/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ The request object parameter has the following properties:
296296
| `method` | `string` | The request method (e.g. `POST`). |
297297
| `headers` | `object` | Used to specify additional headers. |
298298
| `description` | `string` | Used to help identify the upload task locally - not sent to the remote server. |
299+
| `timeout` | `number` | (`iOS only`) Sets the request timeout in seconds (s). |
299300
| `utf8` | `boolean` | (`Android-only`, `multipartUpload()-only`) If true, sets the charset for the multipart request to UTF-8. Default is `false`. |
300301
| `androidNotificationOnProgressTitle` | `string` | Use this to set the on progress title shown in the Android notifications center. |
301302
| `androidNotificationOnProgressMessage` | `string` | Use this to set the on progress message shown in the Android notifications center. |

Diff for: ‎packages/background-http/index.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ export interface Request {
169169
*/
170170
description: string;
171171

172+
/**
173+
* iOS only. Sets NSMutableURLRequest.timeoutInterval value in seconds (s)
174+
*/
175+
timeout?: number
176+
172177
/**
173178
* Use utf8 encode in requests
174179
*/

Diff for: ‎packages/background-http/index.ios.ts

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ class Session implements Session {
177177
request.HTTPMethod = options.method;
178178
}
179179

180+
if (options.timeout) {
181+
request.timeoutInterval = options.timeout;
182+
}
183+
180184
let fileURL: NSURL;
181185
if (fileUri.substr(0, 7) === "file://") {
182186
// File URI in string format

0 commit comments

Comments
 (0)
Please sign in to comment.