Skip to content

Commit

Permalink
Set URLSessionConfiguration timeouts to 30 seconds (#1372)
Browse files Browse the repository at this point in the history
  • Loading branch information
scannillo authored Jul 22, 2024
1 parent 79a0864 commit 94e2236
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
## unreleased
* BraintreeThreeDSecure
* Add error code and error message for `exceededTimeoutLimit`
* Prevent duplicate outbound `v1/configuration` requests
* BraintreeCore
* Prevent duplicate outbound `v1/configuration` requests
* Add network timeout of 30 seconds

## 6.23.0 (2024-07-15)
* BraintreeShopperInsights (BETA)
Expand Down
2 changes: 2 additions & 0 deletions Sources/BraintreeCore/BTHTTP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class BTHTTP: NSObject, URLSessionTaskDelegate {
lazy var session: URLSession = {
let configuration = URLSessionConfiguration.ephemeral
configuration.httpAdditionalHeaders = defaultHeaders
configuration.timeoutIntervalForRequest = 30
configuration.timeoutIntervalForResource = 30

let delegateQueue = OperationQueue()
delegateQueue.name = "com.braintreepayments.BTHTTP"
Expand Down
6 changes: 6 additions & 0 deletions UnitTests/BraintreeCoreTests/BTHTTP_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,12 @@ final class BTHTTP_Tests: XCTestCase {
XCTAssertNotNil(mockDelegate.receivedStartTime)
XCTAssertNotNil(mockDelegate.receivedEndTime)
}

func testURLSessionConfiguration_hasCustomTimeoutSettings() {
let sut = BTHTTP(authorization: fakeTokenizationKey)
XCTAssertEqual(sut.session.configuration.timeoutIntervalForRequest, 30)
XCTAssertEqual(sut.session.configuration.timeoutIntervalForRequest, 30)
}

// MARK: - Helper Methods

Expand Down

0 comments on commit 94e2236

Please sign in to comment.