File tree Expand file tree Collapse file tree 8 files changed +23
-13
lines changed
Expand file tree Collapse file tree 8 files changed +23
-13
lines changed Original file line number Diff line number Diff line change 11Pod ::Spec . new do |spec |
22
33 spec . name = "PublisherKit"
4- spec . version = "4.0.1 "
4+ spec . version = "4.0.2 "
55 spec . summary = "An open source implementation of Apple's Combine framework for processing asynchronous events over time"
66
77 spec . homepage = "https://github.com/ragzy15/PublisherKit"
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ let package = Package(
5151 targets : [" YourPackage" ]),
5252 ],
5353 dependencies : [
54- .package (url : " https://github.com/ragzy15/PublisherKit.git" , from : " 4.0.1 " ),
54+ .package (url : " https://github.com/ragzy15/PublisherKit.git" , from : " 4.0.2 " ),
5555 ],
5656 targets : [
5757 .target (
@@ -80,7 +80,7 @@ source 'https://github.com/CocoaPods/Specs.git'
8080platform :ios , ' 10.0'
8181use_frameworks!
8282
83- pod ' PublisherKit' , ' ~> 4.0.1 '
83+ pod ' PublisherKit' , ' ~> 4.0.2 '
8484```
8585
8686Then, run the following command:
Original file line number Diff line number Diff line change @@ -20,4 +20,10 @@ extension URLError {
2020 NSLocalizedDescriptionKey: " Content data received during a connection request had an unknown content encoding. "
2121 ] )
2222 }
23+
24+ static func onlyHTTPSupported( ) -> Error {
25+ URLError ( . cannotParseResponse, userInfo: [
26+ NSLocalizedDescriptionKey: " Currently Validate only works on HTTP requests. "
27+ ] )
28+ }
2329}
Original file line number Diff line number Diff line change @@ -1260,7 +1260,7 @@ extension Publisher {
12601260}
12611261
12621262// MARK: VALIDATE
1263- extension Publisher where Output == ( data: Data , response: HTTPURLResponse ) {
1263+ extension Publisher where Output == ( data: Data , response: URLResponse ) {
12641264
12651265 /// Validates that the response has a status code acceptable in the specified range, and that the response has a content type in the specified sequence.
12661266 ///
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ extension URLSession {
3939
4040 public struct DataTaskPKPublisher : PublisherKit . Publisher {
4141
42- public typealias Output = ( data: Data , response: HTTPURLResponse )
42+ public typealias Output = ( data: Data , response: URLResponse )
4343
4444 public typealias Failure = Error
4545
@@ -104,7 +104,7 @@ extension URLSession.DataTaskPKPublisher {
104104
105105 if let error = error {
106106 downstream. receive ( completion: . failure( error) )
107- } else if let response = response as? HTTPURLResponse , let data = data {
107+ } else if let response = response, let data = data {
108108 _ = downstream. receive ( ( data, response) )
109109 downstream. receive ( completion: . finished)
110110 } else {
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ extension URLSession {
4949
5050 public struct DownloadTaskPKPublisher : PublisherKit . Publisher {
5151
52- public typealias Output = ( url: URL , response: HTTPURLResponse )
52+ public typealias Output = ( url: URL , response: URLResponse )
5353
5454 public typealias Failure = Error
5555
@@ -129,7 +129,7 @@ extension URLSession.DownloadTaskPKPublisher {
129129
130130 if let error = error {
131131 downstream. receive ( completion: . failure( error) )
132- } else if let url = url, let response = response as? HTTPURLResponse {
132+ } else if let url = url, let response = response {
133133 _ = downstream. receive ( ( url, response) )
134134 downstream. receive ( completion: . finished)
135135 } else {
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ extension URLSession {
4040
4141 public struct UploadTaskPKPublisher : PublisherKit . Publisher {
4242
43- public typealias Output = ( data: Data , response: HTTPURLResponse )
43+ public typealias Output = ( data: Data , response: URLResponse )
4444
4545 public typealias Failure = Error
4646
@@ -124,7 +124,7 @@ extension URLSession.UploadTaskPKPublisher {
124124
125125 if let error = error {
126126 downstream. receive ( completion: . failure( error) )
127- } else if let response = response as? HTTPURLResponse , let data = data {
127+ } else if let response = response, let data = data {
128128 _ = downstream. receive ( ( data, response) )
129129 downstream. receive ( completion: . finished)
130130 } else {
Original file line number Diff line number Diff line change @@ -18,9 +18,9 @@ public enum AcceptableContentTypes {
1818
1919extension Publishers {
2020
21- public struct Validate < Upstream: Publisher > : Publisher where Upstream. Output == ( data: Data , response: HTTPURLResponse ) {
21+ public struct Validate < Upstream: Publisher > : Publisher where Upstream. Output == ( data: Data , response: URLResponse ) {
2222
23- public typealias Output = Upstream . Output
23+ public typealias Output = ( data : Data , response : HTTPURLResponse )
2424
2525 public typealias Failure = Error
2626
@@ -159,7 +159,11 @@ private extension Publishers.Validate.Inner {
159159
160160 func validate( input: Input ) -> Result < Downstream . Input , Downstream . Failure > {
161161
162- let ( data, response) = input
162+ let ( data, _response) = input
163+
164+ guard let response = _response as? HTTPURLResponse else {
165+ return . failure( URLError . onlyHTTPSupported ( ) )
166+ }
163167
164168 guard acceptableStatusCodes. contains ( response. statusCode) else {
165169
You can’t perform that action at this time.
0 commit comments