Skip to content
This repository was archived by the owner on Apr 7, 2021. It is now read-only.

Commit 23a50f5

Browse files
須藤将史須藤将史
authored andcommitted
call invalidateAndCancel
1 parent f6103a3 commit 23a50f5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

StudyplusSDK/StudyplusAPIRequest.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ internal struct StudyplusAPIRequest {
6161

6262
guard let url = buildUrl(path: path) else { return }
6363

64-
let urlSession = URLSession(configuration: URLSessionConfiguration.default)
6564
var request = URLRequest(url: url)
6665
request.httpMethod = method
6766

@@ -74,8 +73,12 @@ internal struct StudyplusAPIRequest {
7473
}
7574

7675
request.addValue("OAuth " + accessToken, forHTTPHeaderField: "HTTP_AUTHORIZATION")
77-
76+
77+
let urlSession = URLSession(configuration: URLSessionConfiguration.default)
7878
let task = urlSession.dataTask(with: request) { (data, response, error) in
79+
80+
urlSession.invalidateAndCancel()
81+
7982
if error == nil && response != nil {
8083
if let httpResponse: HTTPURLResponse = response as? HTTPURLResponse {
8184
if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 || httpResponse.statusCode == 202 {

0 commit comments

Comments
 (0)