// Session configurationTQUICURLSessionConfiguration *quicSessionConfiguration = [TQUICURLSessionConfiguration defaultConfiguration];// Congestion control algorithmquicSessionConfiguration.congestionType = TQUICCongestionTypeBBR;// Connection timeoutquicSessionConfiguration.connectTimeoutMillis = 6 * 1000;// Create SessionManager. See %!s(<nil>) for instructions.TQUICHTTPSessionManager *quicSessionManager = [[TQUICHTTPSessionManager alloc] initWithSessionConfiguration:quicSessionConfiguration];// (Optional) Serialize via TQUICHTTPRequestSerializer/TQUICHTTPResponseSerializer. See %!s(<nil>) for instructions.// Initiate a GET request.[quicSessionManager GET:@"url"parameters:nilheaders:niltimeoutInterval:0downloadProgress:nilsuccess:^(TQUICURLSessionTask * _Nonnull task, id _Nullable responseObject) {// When the request is executed successfully, it returns the response data.// Get the response headers. Since this is an HTTP response, it can be converted into NSHTTPURLResponse.NSDictionary *headers = [(NSHTTPURLResponse *)task.response allHeaderFields];// Get the response body.id body = responseObject;} failure:^(TQUICURLSessionTask * _Nullable task, NSError * _Nonnull error) {// When the request fails to be executed, it returns the error message.NSInteger errorCode = error.code;}];
// Session configurationTQUICURLSessionConfiguration *quicSessionConfiguration = [TQUICURLSessionConfiguration defaultConfiguration];// Congestion control algorithmquicSessionConfiguration.congestionType = TQUICCongestionTypeBBR;// Connection timeoutquicSessionConfiguration.connectTimeoutMillis = 6 * 1000;// Create SessionManager. See %!s(<nil>) for instructions.TQUICHTTPSessionManager *quicSessionManager = [[TQUICHTTPSessionManager alloc] initWithSessionConfiguration:quicSessionConfiguration];// (Optional) Serialize via TQUICHTTPRequestSerializer/TQUICHTTPResponseSerializer. See %!s(<nil>) for instructions.// Construct body data.NSData *bodyData;// Initiate a POST request.[quicSessionManager POST:@"url"body:bodyDataheaders:niltimeoutInterval:timeIntervaluploadProgress:^(NSProgress * _Nonnull uploadProgress) {} success:^(TQUICURLSessionTask * _Nonnull task, id _Nullable responseObject) {// When the request is executed successfully, it returns the response data.// Get the response body.id body = responseObject;} failure:^(TQUICURLSessionTask * _Nullable task, NSError * _Nonnull error) {// When the request fails to be executed, it returns the error message.NSInteger errorCode = error.code;}];
// Create SessionManager....// Initiate a request via SessionDataTask. See %!s(<nil>) for instructions.TQUICURLSessionDataTask *dataTask =[quicSessionManager dataTaskWithRequest:requestuploadProgress:nildownloadProgress:nilcompletionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {// Run callback after the request has finished.}];//Send the request.[dataTask resume];//Cancel the request.[dataTask cancel];
Was this page helpful?