diff options
| author | Vincent Neo <23420208+vincentneo@users.noreply.github.com> | 2023-07-21 18:25:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-21 13:25:32 +0300 |
| commit | ddd7c3ea361b38acf5c61079f5460e6e0f110d70 (patch) | |
| tree | 12b6eca1df2df92a408ba060b12423ab93a79204 /tdnet | |
| parent | 2e5319ff360cd2d6dab638a7e0370fe959e4201b (diff) | |
waitsForConnectivity, configurations for URLSession (#2501)
Diffstat (limited to 'tdnet')
| -rw-r--r-- | tdnet/td/net/DarwinHttp.mm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tdnet/td/net/DarwinHttp.mm b/tdnet/td/net/DarwinHttp.mm index 1b90e59ad..3195c7a0d 100644 --- a/tdnet/td/net/DarwinHttp.mm +++ b/tdnet/td/net/DarwinHttp.mm @@ -14,6 +14,18 @@ namespace td { namespace { + +NSURLSession *getSession() { + static NSURLSession *urlSession = [] { + auto configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + configuration.networkServiceType = NSURLNetworkServiceTypeResponsiveData; + configuration.timeoutIntervalForResource = 90; + configuration.waitsForConnectivity = true; + return [NSURLSession sessionWithConfiguration:configuration]; + }(); + return urlSession; +} + NSString *to_ns_string(CSlice slice) { return [NSString stringWithUTF8String:slice.c_str()]; } @@ -43,7 +55,7 @@ auto http_post(CSlice url, Slice data) { void http_send(NSURLRequest *request, Promise<BufferSlice> promise) { __block auto callback = std::move(promise); NSURLSessionDataTask *dataTask = - [NSURLSession.sharedSession + [getSession() dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) { |
