Skip to content

Commit

Permalink
Release 0.21.0 (#151)
Browse files Browse the repository at this point in the history
Release 0.21.0
  • Loading branch information
eneko authored Apr 6, 2020
1 parent 66454a1 commit dacaf06
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@
- None


## 0.21.0

#### Breaking
- `ResponsePipelineMiddleware` protocol has been updated.

#### Enhancements
- Surface request metrics to response middleware
- `SessionDelegate` has been updated to capture request metrics in `TaskResponse`.
- `URLSessionClient` has been updated to pass `TaskResponse` to any response middleware.
- `ResponsePipelineMiddleware` has been refactored to pass a `TaskResponse` structure.

#### Bug Fixes
- None

#### Other
- Unit test updates
- Existing unit tests updated as needed, and new tests have been added.
- Private `URL` extension has been moved to test targets.
- `@testable` imports have been removed where possible.


## 0.20.0

#### Breaking
Expand Down
2 changes: 1 addition & 1 deletion Conduit.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version = '0.20.0'
$version = '0.21.0'

Pod::Spec.new do |spec|
spec.name = 'Conduit'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ import PackageDescription

let package = Package(
dependencies: [
.package(url: "https://github.com/mindbody/Conduit.git", from: "0.20.0")
.package(url: "https://github.com/mindbody/Conduit.git", from: "0.21.0")
]
)
```
Expand Down
2 changes: 1 addition & 1 deletion Sources/Conduit/Networking/TaskResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct TaskResponse {
public var response: HTTPURLResponse?
public var error: Error?

@available(iOS 10, *)
@available(iOS 10, macOS 10.12, tvOS 10, watchOS 3, *)
public lazy var metrics: URLSessionTaskMetrics? = nil

var expectedContentLength: Int64?
Expand Down
2 changes: 1 addition & 1 deletion Sources/Conduit/Networking/URLSessionClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private class SessionDelegate: NSObject, URLSessionDataDelegate {

/// Stores request metrics in task response, for later consumption.
/// This delegate method is always called after `didReceive response`, and before `didCompleteWithError`.
@available(iOS 10.0, *)
@available(iOS 10, macOS 10.12, tvOS 10, watchOS 3, *)
func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) {
var taskResponse = taskResponseFor(taskIdentifier: task.taskIdentifier)
taskResponse.metrics = metrics
Expand Down
2 changes: 1 addition & 1 deletion Sources/Conduit/Networking/URLSessionClientLogging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension URLSessionClient {
var requestDurationString: String = ""
var taskResponse = taskResponse

if #available(iOS 10, *) {
if #available(iOS 10, macOS 10.12, tvOS 10, watchOS 3, *) {
if let interval = taskResponse.metrics?.taskInterval.duration {
requestDurationString = String(format: "(%0.2f sec)", interval)
}
Expand Down
1 change: 1 addition & 0 deletions Tests/ConduitTests/Networking/URLSessionClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class URLSessionClientTests: XCTestCase {
XCTAssertEqual(text, "\(baseResponseText)abc")
}

@available(iOS 10, macOS 10.12, tvOS 10, watchOS 3, *)
func testRequestMetrics() throws {
let expectation = self.expectation(description: "Middleware gets called")
let responseMiddleware = TransformingResponseMiddleware { taskResponse in
Expand Down

0 comments on commit dacaf06

Please sign in to comment.