Skip to content

Commit 5031d18

Browse files
Merge branch 'http-headers'
2 parents 05a351b + 9d1b8fd commit 5031d18

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

SwiftStomp/Classes/SwiftStomp.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ fileprivate enum StompLogType : String{
9191
public class SwiftStomp{
9292

9393
fileprivate var host : URL
94-
fileprivate var connectionHeaders : [String : String]?
94+
fileprivate var httpConnectionHeaders : [String : String]?
95+
fileprivate var stompConnectionHeaders : [String : String]?
9596
fileprivate var socket : WebSocket!
9697
fileprivate var acceptVersion = "1.1,1.2"
9798
fileprivate var status : StompConnectionStatus = .socketDisconnected
@@ -117,11 +118,12 @@ public class SwiftStomp{
117118
public var callbacksThread : DispatchQueue?
118119
public var autoReconnect = false
119120

120-
public init (host : URL, headers : [String : String]? = nil){
121+
public init (host : URL, headers : [String : String]? = nil, httpConnectionHeaders : [String : String]? = nil){
121122
self.host = host
122-
self.connectionHeaders = headers
123123

124124

125+
self.stompConnectionHeaders = headers
126+
self.httpConnectionHeaders = httpConnectionHeaders
125127
/// Configure reachability
126128
self.initReachability()
127129
}
@@ -159,8 +161,13 @@ public extension SwiftStomp{
159161

160162
//** Time interval
161163
urlRequest.timeoutInterval = timeout
162-
163-
164+
165+
if let httpConnectionHeaders {
166+
for header in httpConnectionHeaders {
167+
urlRequest.addValue(header.value, forHTTPHeaderField: header.key)
168+
}
169+
}
170+
164171
//** Connect
165172
self.socket = WebSocket(request: urlRequest)
166173

@@ -395,8 +402,8 @@ fileprivate extension SwiftStomp{
395402
.get
396403

397404
//** Append connection headers
398-
if let connectionHeaders = self.connectionHeaders{
399-
for (hKey, hVal) in connectionHeaders{
405+
if let stompConnectionHeaders = self.stompConnectionHeaders{
406+
for (hKey, hVal) in stompConnectionHeaders{
400407
headers[hKey] = hVal
401408
}
402409
}

0 commit comments

Comments
 (0)