Skip to content

Commit

Permalink
adding new makeURL method in preparation for future release
Browse files Browse the repository at this point in the history
  • Loading branch information
henrik-dmg committed Mar 20, 2021
1 parent 7a12d27 commit 63a7469
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion HPNetwork.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "HPNetwork"
s.version = "1.2.0"
s.version = "1.2.1"
s.summary = "A lightweight but customisable networking stack written in Swift"

s.homepage = "https://panhans.dev/opensource/hpnetwork"
Expand Down
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
MIT License

Copyright (c) 2019 Henrik Panhans
Copyright (c) 2021 Henrik Panhans

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 changes: 12 additions & 3 deletions Sources/HPNetwork/Requests/NetworkRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ public protocol NetworkRequest {
typealias Completion = (RequestResult) -> Void

var finishingQueue: DispatchQueue { get }
@available(*, deprecated, message: "Please use makeURL instead, this property will be removed in a future release")
var url: URL? { get }
var httpBody: Data? { get }
var urlSession: URLSession { get }

func makeURL() throws -> URL

var headerFields: [NetworkRequestHeaderField]? { get }
/// The request method that will be used
var requestMethod: NetworkRequestMethod { get }
var authentication: NetworkRequestAuthentication? { get }

Expand All @@ -26,9 +30,7 @@ public protocol NetworkRequest {
extension NetworkRequest {

func makeURLRequest() throws -> URLRequest {
guard let url = url else {
throw NSError.failedToCreateRequest.withFailureReason("The URL instance to create the request is nil")
}
let url = try makeURL()

var request = URLRequest(url: url)
request.httpMethod = requestMethod.rawValue
Expand Down Expand Up @@ -61,6 +63,13 @@ public extension NetworkRequest {

var authentication: NetworkRequestAuthentication? { nil }

func makeURL() throws -> URL {
guard let url = url else {
throw NSError.failedToCreateRequest.withFailureReason("The URL instance to create the request is nil")
}
return url
}

func convertError(_ error: Error, data: Data?, response: URLResponse?) -> Error {
error
}
Expand Down

0 comments on commit 63a7469

Please sign in to comment.