@@ -91,7 +91,8 @@ fileprivate enum StompLogType : String{
9191public 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