forked from loafle/openapi-generator-original
parent
6a77660b08
commit
5f1f47d156
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func createURLSession() -> URLSession {
|
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
internal protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ internal class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
internal func createURLSession() -> URLSession {
|
internal func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ internal class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
internal func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
internal func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
@ -9,6 +9,12 @@ import Foundation
|
|||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public protocol URLSessionProtocol {
|
||||||
|
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||||
|
}
|
||||||
|
|
||||||
|
extension URLSession: URLSessionProtocol {}
|
||||||
|
|
||||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
return URLSessionRequestBuilder<T>.self
|
return URLSessionRequestBuilder<T>.self
|
||||||
@ -57,7 +63,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLSession
|
May be overridden by a subclass if you want to control the URLSession
|
||||||
configuration.
|
configuration.
|
||||||
*/
|
*/
|
||||||
open func createURLSession() -> URLSession {
|
open func createURLSession() -> URLSessionProtocol {
|
||||||
return defaultURLSession
|
return defaultURLSession
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +82,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
May be overridden by a subclass if you want to control the URLRequest
|
May be overridden by a subclass if you want to control the URLRequest
|
||||||
configuration (e.g. to override the cache policy).
|
configuration (e.g. to override the cache policy).
|
||||||
*/
|
*/
|
||||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||||
|
|
||||||
guard let url = URL(string: URLString) else {
|
guard let url = URL(string: URLString) else {
|
||||||
throw DownloadException.requestMissingURL
|
throw DownloadException.requestMissingURL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user