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