@@ -104,6 +104,11 @@ - (void) connectToHost:(NSString *)host onPort:(NSInteger)port withParams:(NSDic
104
104
[self connectToHost: host onPort: port withParams: params withNamespace: @" " withConnectionTimeout: defaultConnectionTimeout];
105
105
}
106
106
107
+ - (void ) connectToHost : (NSString *)host onPort : (NSInteger )port withParams : (NSDictionary *)params withCookieParams : (NSDictionary *)cookieParams
108
+ {
109
+ [self connectToHost: host onPort: port withParams: params withCookieParams: cookieParams withNamespace: @" " withConnectionTimeout: defaultConnectionTimeout];
110
+ }
111
+
107
112
- (void ) connectToHost : (NSString *)host
108
113
onPort : (NSInteger )port
109
114
withParams : (NSDictionary *)params
@@ -112,11 +117,30 @@ - (void) connectToHost:(NSString *)host
112
117
[self connectToHost: host onPort: port withParams: params withNamespace: endpoint withConnectionTimeout: defaultConnectionTimeout];
113
118
}
114
119
120
+ - (void ) connectToHost : (NSString *)host
121
+ onPort : (NSInteger )port
122
+ withParams : (NSDictionary *)params
123
+ withCookieParams : (NSDictionary *)cookieParams
124
+ withNamespace : (NSString *)endpoint
125
+ {
126
+ [self connectToHost: host onPort: port withParams: params withCookieParams: cookieParams withNamespace: endpoint withConnectionTimeout: defaultConnectionTimeout];
127
+ }
128
+
115
129
- (void ) connectToHost : (NSString *)host
116
130
onPort : (NSInteger )port
117
131
withParams : (NSDictionary *)params
118
132
withNamespace : (NSString *)endpoint
119
133
withConnectionTimeout : (NSTimeInterval )connectionTimeout
134
+ {
135
+ [self connectToHost: host onPort: port withParams: params withCookieParams: nil withNamespace: endpoint withConnectionTimeout: defaultConnectionTimeout];
136
+ }
137
+
138
+ - (void ) connectToHost : (NSString *)host
139
+ onPort : (NSInteger )port
140
+ withParams : (NSDictionary *)params
141
+ withCookieParams : (NSDictionary *)cookieParams
142
+ withNamespace : (NSString *)endpoint
143
+ withConnectionTimeout : (NSTimeInterval )connectionTimeout
120
144
{
121
145
if (!_isConnected && !_isConnecting) {
122
146
_isConnecting = YES ;
@@ -142,10 +166,19 @@ - (void) connectToHost:(NSString *)host
142
166
query = nil ;
143
167
144
168
// make a request
145
- NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString: handshakeUrl]
169
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: handshakeUrl]
146
170
cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData
147
171
timeoutInterval: connectionTimeout];
148
172
173
+ if (cookieParams) {
174
+ NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties: cookieParams];
175
+ NSArray * cookieArray = [NSArray arrayWithObjects: cookie, nil ];
176
+ NSDictionary * headers = [NSHTTPCookie requestHeaderFieldsWithCookies: cookieArray];
177
+ [request setAllHTTPHeaderFields: headers];
178
+ }
179
+
180
+ [request setHTTPShouldHandleCookies: YES ];
181
+
149
182
_handshake = [[NSURLConnection alloc ] initWithRequest: request delegate: self startImmediately: NO ];
150
183
[_handshake scheduleInRunLoop: [NSRunLoop mainRunLoop ] forMode: NSDefaultRunLoopMode ];
151
184
[_handshake start ];
0 commit comments