waitsForConnectivity, configurations for URLSession (#2501)
This commit is contained in:
parent
2e5319ff36
commit
ddd7c3ea36
@ -14,6 +14,18 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
namespace {
|
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) {
|
NSString *to_ns_string(CSlice slice) {
|
||||||
return [NSString stringWithUTF8String:slice.c_str()];
|
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) {
|
void http_send(NSURLRequest *request, Promise<BufferSlice> promise) {
|
||||||
__block auto callback = std::move(promise);
|
__block auto callback = std::move(promise);
|
||||||
NSURLSessionDataTask *dataTask =
|
NSURLSessionDataTask *dataTask =
|
||||||
[NSURLSession.sharedSession
|
[getSession()
|
||||||
dataTaskWithRequest:request
|
dataTaskWithRequest:request
|
||||||
completionHandler:
|
completionHandler:
|
||||||
^(NSData *data, NSURLResponse *response, NSError *error) {
|
^(NSData *data, NSURLResponse *response, NSError *error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user