Skip to content

Commit f72d45d

Browse files
committed
II-15-[fixed warnings]
1 parent 961698a commit f72d45d

File tree

7 files changed

+21
-41
lines changed

7 files changed

+21
-41
lines changed

HTTPClient_Example.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
1CD8196AD84A0A39D8695A38 /* Pods_HTTPClient_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95981F67F5807ED7C84A1F24 /* Pods_HTTPClient_Example.framework */; };
1111
A5716D99271E7E6400844212 /* ExampleHTTPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5716D98271E7E6400844212 /* ExampleHTTPClient.swift */; };
1212
A5716D9C271E850A00844212 /* ExampleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5716D9B271E850A00844212 /* ExampleCell.swift */; };
13-
A5B34F5C27019163005F23C5 /* ExampleHTTPLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5B34F5B27019163005F23C5 /* ExampleHTTPLogger.swift */; };
1413
F006A29726989C1D00F0A062 /* HTTPClient_Framework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F006A29626989C1D00F0A062 /* HTTPClient_Framework.framework */; };
1514
F006A29826989C1D00F0A062 /* HTTPClient_Framework.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F006A29626989C1D00F0A062 /* HTTPClient_Framework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1615
F0B2E9D626EA39D600CCA6B9 /* ExampleParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B2E9D526EA39D600CCA6B9 /* ExampleParser.swift */; };
@@ -41,7 +40,6 @@
4140
95981F67F5807ED7C84A1F24 /* Pods_HTTPClient_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HTTPClient_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4241
A5716D98271E7E6400844212 /* ExampleHTTPClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleHTTPClient.swift; sourceTree = "<group>"; };
4342
A5716D9B271E850A00844212 /* ExampleCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleCell.swift; sourceTree = "<group>"; };
44-
A5B34F5B27019163005F23C5 /* ExampleHTTPLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleHTTPLogger.swift; sourceTree = "<group>"; };
4543
B0E8B7441542246515DCACF1 /* Pods-HTTPClient_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HTTPClient_Example.release.xcconfig"; path = "Target Support Files/Pods-HTTPClient_Example/Pods-HTTPClient_Example.release.xcconfig"; sourceTree = "<group>"; };
4644
F006A29626989C1D00F0A062 /* HTTPClient_Framework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = HTTPClient_Framework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4745
F0B2E9D526EA39D600CCA6B9 /* ExampleParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleParser.swift; sourceTree = "<group>"; };
@@ -119,7 +117,6 @@
119117
children = (
120118
A5716D98271E7E6400844212 /* ExampleHTTPClient.swift */,
121119
F0B2E9D726EA3AF800CCA6B9 /* ExampleAPIEndPoint.swift */,
122-
A5B34F5B27019163005F23C5 /* ExampleHTTPLogger.swift */,
123120
F0B2E9D526EA39D600CCA6B9 /* ExampleParser.swift */,
124121
);
125122
path = HTTPClient;
@@ -289,7 +286,6 @@
289286
isa = PBXSourcesBuildPhase;
290287
buildActionMask = 2147483647;
291288
files = (
292-
A5B34F5C27019163005F23C5 /* ExampleHTTPLogger.swift in Sources */,
293289
F0EBCB4F26989A7E006A2695 /* ExampleViewController.swift in Sources */,
294290
F0B2E9D826EA3AF800CCA6B9 /* ExampleAPIEndPoint.swift in Sources */,
295291
A5716D99271E7E6400844212 /* ExampleHTTPClient.swift in Sources */,

HTTPClient_Example/HTTPClient/ExampleHTTPClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal final class ExampleHTTPClient: HTTPClientProtocol {
1313
internal init() {
1414
self.httpClient = HTTPClient(name: "ExampleHTTPClient",
1515
configuration: nil,
16-
logger: ExampleHTTPLogger(),
16+
logger: HTTPClientLoggerFull(logAction: { print($0) }),
1717
commonHeaders: [])
1818
}
1919

HTTPClient_Example/HTTPClient/ExampleHTTPLogger.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

HTTPClient_Example/HTTPClient/ExampleParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Foundation
66
import HTTPClient_Framework
77

8-
class ExampleParser: HTTPClientParser {
8+
final class ExampleParser: HTTPClientParser {
99

1010
internal struct Contributor {
1111
internal let identifier: Int

Source/HTTPClientLogger.swift

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import Alamofire
77
import Foundation
88

9-
public protocol HTTPClientLogger {
9+
public protocol HTTPClientLogger: Sendable {
1010

1111
/// Request was formed with provided options and headers.
1212
/// Called before adding validator/serializers to said request and starting it.
@@ -63,49 +63,49 @@ public protocol HTTPClientLogger {
6363

6464
}
6565

66-
open class HTTPClientLoggerNone: HTTPClientLogger {
66+
public final class HTTPClientLoggerNone: HTTPClientLogger {
6767

6868
public init() {}
6969

70-
open func clientDidCreateRequest<ParserType: HTTPClientParser, EndpointType>(
70+
public func clientDidCreateRequest<ParserType: HTTPClientParser, EndpointType>(
7171
requestOptions: HTTPClientRequestOptions<ParserType, EndpointType>,
7272
resolvedHeaders: Alamofire.HTTPHeaders) { }
7373

74-
open func clientDidReceiveResponse<ParserType: HTTPClientParser, EndpointType>(
74+
public func clientDidReceiveResponse<ParserType: HTTPClientParser, EndpointType>(
7575
requestOptions: HTTPClientRequestOptions<ParserType, EndpointType>,
7676
request: URLRequest?,
7777
response: HTTPURLResponse?,
7878
responseData: Data?,
7979
responseError: Error?) {}
8080

81-
open func requestWasCancelled<ParserType: HTTPClientParser, EndpointType>(
81+
public func requestWasCancelled<ParserType: HTTPClientParser, EndpointType>(
8282
requestOptions: HTTPClientRequestOptions<ParserType, EndpointType>,
8383
request: URLRequest?,
8484
response: HTTPURLResponse?,
8585
responseData: Data?) {}
8686

87-
open func parserDidFindError<ParserType: HTTPClientParser, EndpointType>(
87+
public func parserDidFindError<ParserType: HTTPClientParser, EndpointType>(
8888
requestOptions: HTTPClientRequestOptions<ParserType, EndpointType>,
8989
request: URLRequest?,
9090
response: HTTPURLResponse?,
9191
responseData: Data?,
9292
parsedError: Swift.Error) {}
9393

94-
open func clientDidEncounterNetworkError<ParserType: HTTPClientParser, EndpointType>(
94+
public func clientDidEncounterNetworkError<ParserType: HTTPClientParser, EndpointType>(
9595
requestOptions: HTTPClientRequestOptions<ParserType, EndpointType>,
9696
request: URLRequest?,
9797
response: HTTPURLResponse?,
9898
responseData: Data?,
9999
networkError: Swift.Error) {}
100100

101-
open func clientDidEncounterSerializationError<ParserType: HTTPClientParser, EndpointType>(
101+
public func clientDidEncounterSerializationError<ParserType: HTTPClientParser, EndpointType>(
102102
requestOptions: HTTPClientRequestOptions<ParserType, EndpointType>,
103103
request: URLRequest?,
104104
response: HTTPURLResponse?,
105105
responseData: Data?,
106106
serializationError: Swift.Error) {}
107107

108-
open func clientDidEncounterParseError<ParserType: HTTPClientParser, EndpointType>(
108+
public func clientDidEncounterParseError<ParserType: HTTPClientParser, EndpointType>(
109109
requestOptions: HTTPClientRequestOptions<ParserType, EndpointType>,
110110
request: URLRequest?,
111111
response: HTTPURLResponse?,
@@ -115,11 +115,12 @@ open class HTTPClientLoggerNone: HTTPClientLogger {
115115
}
116116

117117
/// Full logger, intended for subclassing to provide actual method to output logs.
118-
open class HTTPClientLoggerFull {
118+
public final class HTTPClientLoggerFull {
119119

120120
private let tab: String
121121
private let parametersToCensor: [String]
122122
private let censoredValue: String
123+
private let logAction: @Sendable (_ message: String) -> Void
123124

124125
/// - parameter tab: value used for indentation in multiline messages.
125126
/// Default value is ` ` (4 spaces).
@@ -130,14 +131,12 @@ open class HTTPClientLoggerFull {
130131
/// Default value is `xxxxxx`.
131132
public init(tab: String = " ",
132133
parametersToCensor: [String] = [],
133-
censoredValue: String = "xxxxxx") {
134+
censoredValue: String = "xxxxxx",
135+
logAction: @escaping @Sendable (_ message: String) -> Void) {
134136
self.tab = tab
135137
self.parametersToCensor = parametersToCensor
136138
self.censoredValue = censoredValue
137-
}
138-
139-
open func log(_ message: String) {
140-
fatalError("abstract")
139+
self.logAction = logAction
141140
}
142141

143142
private func censorParameters(_ parameters: [String: any Any & Sendable]) -> [String: any Any & Sendable] {
@@ -148,7 +147,7 @@ open class HTTPClientLoggerFull {
148147
return censoredParameters
149148
}
150149

151-
open func generateResponseDataDebugDescription(_ responseData: Data?) -> String? {
150+
public func generateResponseDataDebugDescription(_ responseData: Data?) -> String? {
152151
guard let data = responseData, !data.isEmpty else {
153152
return nil
154153
}
@@ -197,7 +196,7 @@ extension HTTPClientLoggerFull: HTTPClientLogger {
197196
requestDescription.append("\n\(tab)authCredential: \(credentialForLog)")
198197
}
199198

200-
log(requestDescription)
199+
logAction(requestDescription)
201200
}
202201

203202
public func clientDidReceiveResponse<ParserType: HTTPClientParser, EndpointType>(
@@ -234,7 +233,7 @@ extension HTTPClientLoggerFull: HTTPClientLogger {
234233
responseDescription.append("\n\(tab)headers:\n\(responseHeaderDescription)")
235234
responseDescription.append("\n\(tab)data:\n\(responseDataDescription)")
236235

237-
log(responseDescription)
236+
logAction(responseDescription)
238237
}
239238

240239
public func requestWasCancelled<ParserType: HTTPClientParser, EndpointType>(

Source/HTTPClientParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import Foundation
77

8-
public protocol HTTPClientParser {
8+
public protocol HTTPClientParser: Sendable {
99

1010
associatedtype ResultType
1111
associatedtype ResponseValueType

Source/HTTPClientRequestOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import Alamofire
66

7-
public struct HTTPClientRequestOptions<ParserType: HTTPClientParser, EndpointType: HTTPClientAPIEndPoint> {
7+
public struct HTTPClientRequestOptions<ParserType: HTTPClientParser, EndpointType: HTTPClientAPIEndPoint>: Sendable {
88

99
public let endpoint: EndpointType
1010
public let method: Alamofire.HTTPMethod

0 commit comments

Comments
 (0)