@@ -164,7 +164,7 @@ public class SocketEngine: NSObject, WebSocketDelegate {
164
164
self . ws = WebSocket ( url: NSURL ( string: self . urlWebSocket! + " &sid= \( self . sid) " ) !)
165
165
self . ws? . queue = self . handleQueue
166
166
self . ws? . delegate = self
167
-
167
+
168
168
if connect {
169
169
self . ws? . connect ( )
170
170
}
@@ -184,16 +184,19 @@ public class SocketEngine: NSObject, WebSocketDelegate {
184
184
}
185
185
186
186
self . waitingForPoll = true
187
- let req = NSURLRequest ( URL: NSURL ( string: self . urlPolling! + " &sid= \( self . sid) &b64=1 " ) !)
187
+ let req = NSMutableURLRequest ( URL: NSURL ( string: self . urlPolling! + " &sid= \( self . sid) &b64=1 " ) !)
188
188
189
189
self . doRequest ( req)
190
190
}
191
191
192
- private func doRequest( req: NSURLRequest ) {
192
+ private func doRequest( req: NSMutableURLRequest ) {
193
193
if !self . polling {
194
194
return
195
195
}
196
196
197
+ req. cachePolicy = NSURLRequestCachePolicy . ReloadIgnoringLocalAndRemoteCacheData
198
+
199
+ // NSLog("Doing request: \(req)")
197
200
self . session. dataTaskWithRequest ( req) { [ weak self] data, res, err in
198
201
if self == nil {
199
202
return
@@ -205,7 +208,7 @@ public class SocketEngine: NSObject, WebSocketDelegate {
205
208
return
206
209
}
207
210
208
- // println(data )
211
+ // NSLog("Got response: \(res)" )
209
212
210
213
if let str = NSString ( data: data, encoding: NSUTF8StringEncoding) as? String {
211
214
dispatch_async ( self !. parseQueue) {
@@ -219,7 +222,7 @@ public class SocketEngine: NSObject, WebSocketDelegate {
219
222
if self !. fastUpgrade {
220
223
self ? . doFastUpgrade ( )
221
224
return
222
- } else if !self !. closed {
225
+ } else if !self !. closed && ! self ! . websocket {
223
226
self ? . doPoll ( )
224
227
}
225
228
} . resume ( )
@@ -369,6 +372,7 @@ public class SocketEngine: NSObject, WebSocketDelegate {
369
372
length += chr
370
373
} else {
371
374
if length == " " || testLength ( length, & n) {
375
+ NSLog ( " parsing error: \( str) " )
372
376
self . handlePollingFailed ( " Error parsing XHR message " )
373
377
return
374
378
}
@@ -377,7 +381,7 @@ public class SocketEngine: NSObject, WebSocketDelegate {
377
381
378
382
if let lengthInt = length. toInt ( ) {
379
383
if lengthInt != msg. length {
380
- println ( " parsing error " )
384
+ NSLog ( " parsing error: \( str ) " )
381
385
return
382
386
}
383
387
}
0 commit comments