This commit is contained in:
Erik Little 2017-11-14 10:18:49 -05:00
parent 943e94ed0e
commit 3525caedd1
No known key found for this signature in database
GPG Key ID: 62F837E56F4E9320
4 changed files with 13 additions and 5 deletions

View File

@ -44,6 +44,9 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll
}
}
/// A dictionary of extra http headers that will be set during connection.
public var extraHeaders: [String: String]?
/// A queue of engine.io messages waiting for POSTing
///
/// **You should not touch this directly**
@ -73,9 +76,6 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll
/// An array of HTTPCookies that are sent during the connection.
public private(set) var cookies: [HTTPCookie]?
/// A dictionary of extra http headers that will be set during connection.
public private(set) var extraHeaders: [String: String]?
/// When `true`, the engine is in the process of switching to WebSockets.
///
/// **Do not touch this directly**

View File

@ -52,7 +52,7 @@ import Starscream
var engineQueue: DispatchQueue { get }
/// A dictionary of extra http headers that will be set during connection.
var extraHeaders: [String: String]? { get }
var extraHeaders: [String: String]? { get set }
/// When `true`, the engine is in the process of switching to WebSockets.
var fastUpgrade: Bool { get }

View File

@ -192,6 +192,14 @@ class SocketEngineTest: XCTestCase {
XCTAssertTrue(manager.engine!.forceWebsockets)
}
func testChangingEngineHeadersAfterInit() {
engine.extraHeaders = ["Hello": "World"]
let req = engine.createRequestForPostWithPostWait()
XCTAssertEqual("World", req.allHTTPHeaderFields?["Hello"])
}
var manager: SocketManager!
var socket: SocketIOClient!
var engine: SocketEngine!

View File

@ -450,7 +450,7 @@ class TestEngine : SocketEngineSpec {
var connectParams: [String: Any]? = nil
private(set) var cookies: [HTTPCookie]? = nil
private(set) var engineQueue = DispatchQueue.main
private(set) var extraHeaders: [String: String]? = nil
var extraHeaders: [String: String]? = nil
private(set) var fastUpgrade = false
private(set) var forcePolling = false
private(set) var forceWebsockets = false