From d28dec3c4ecc090271b352a9d79ac0f5858f051a Mon Sep 17 00:00:00 2001 From: Enea Dume Date: Mon, 20 Nov 2023 17:01:47 +0100 Subject: [PATCH 1/3] added httpCookieStorage and httpHeaders --- netfox/Core/NFX.swift | 3 +++ netfox/Core/NFXProtocol.swift | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/netfox/Core/NFX.swift b/netfox/Core/NFX.swift index eaf2eab9..f872b250 100755 --- a/netfox/Core/NFX.swift +++ b/netfox/Core/NFX.swift @@ -69,6 +69,9 @@ open class NFX: NSObject { case shake case custom } + // There are some cases while using Alamofire we needd to store cookies in the default http storage + @objc public static var globalCookieStorage: HTTPCookieStorage? + @objc public static var defaultHTTPHeaders: [String: String]? @objc open func start() { guard !started else { diff --git a/netfox/Core/NFXProtocol.swift b/netfox/Core/NFXProtocol.swift index db49585d..d6f45fc3 100755 --- a/netfox/Core/NFXProtocol.swift +++ b/netfox/Core/NFXProtocol.swift @@ -12,7 +12,14 @@ open class NFXProtocol: URLProtocol { static let nfxInternalKey = "com.netfox.NFXInternal" private lazy var session: URLSession = { [unowned self] in - return URLSession(configuration: .default, delegate: self, delegateQueue: nil) + let config = URLSessionConfiguration.default + if let globalCookieStorage = NFX.globalCookieStorage { + config.httpCookieStorage = NFX.globalCookieStorage + } + if let defaultHTTPHeaders = NFX.defaultHTTPHeaders { + config.httpAdditionalHeaders = defaultHTTPHeaders + } + return URLSession(configuration: config, delegate: self, delegateQueue: nil) }() private let model = NFXHTTPModel() From 407d6cac150c42e7b578975a4780bd2cc94ce242 Mon Sep 17 00:00:00 2001 From: Enea Dume Date: Wed, 22 Nov 2023 11:38:53 +0100 Subject: [PATCH 2/3] updated httpHeaders type to [AnyHashable: String] --- netfox/Core/NFX.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netfox/Core/NFX.swift b/netfox/Core/NFX.swift index f872b250..012be21c 100755 --- a/netfox/Core/NFX.swift +++ b/netfox/Core/NFX.swift @@ -71,7 +71,7 @@ open class NFX: NSObject { } // There are some cases while using Alamofire we needd to store cookies in the default http storage @objc public static var globalCookieStorage: HTTPCookieStorage? - @objc public static var defaultHTTPHeaders: [String: String]? + @objc public static var defaultHTTPHeaders: [AnyHashable: String]? @objc open func start() { guard !started else { From f0a2d16ed54dddb6522174bd25cbc26b03f6337e Mon Sep 17 00:00:00 2001 From: Enea Dume Date: Wed, 22 Nov 2023 11:43:26 +0100 Subject: [PATCH 3/3] updated httpHeaders type to [AnyHashable: Any] --- netfox/Core/NFX.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netfox/Core/NFX.swift b/netfox/Core/NFX.swift index 012be21c..0e0a51e8 100755 --- a/netfox/Core/NFX.swift +++ b/netfox/Core/NFX.swift @@ -71,7 +71,7 @@ open class NFX: NSObject { } // There are some cases while using Alamofire we needd to store cookies in the default http storage @objc public static var globalCookieStorage: HTTPCookieStorage? - @objc public static var defaultHTTPHeaders: [AnyHashable: String]? + @objc public static var defaultHTTPHeaders: [AnyHashable: Any]? @objc open func start() { guard !started else {