Merge branch 'development'
* development: update changelog and bump pod version check for 200 status code when polling #857 update xcode versino set the right URL in websocket creation fix cookies import when create the websocket Be sure to keep secure config even if config is changed. Fix #1078 Don't need to write DispatchTime use while let instead of while and if let
This commit is contained in:
		
						commit
						016e12720d
					
				@ -1,7 +1,7 @@
 | 
			
		||||
language: objective-c
 | 
			
		||||
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
 | 
			
		||||
xcode_scheme: SocketIO-Mac
 | 
			
		||||
osx_image: xcode9.2
 | 
			
		||||
osx_image: xcode10
 | 
			
		||||
branches:
 | 
			
		||||
  only:
 | 
			
		||||
    - master
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,7 @@
 | 
			
		||||
# v13.3.1
 | 
			
		||||
 | 
			
		||||
- Fixes various bugs. [#857](https://github.com/socketio/socket.io-client-swift/issues/857), [#1078](https://github.com/socketio/socket.io-client-swift/issues/1078)
 | 
			
		||||
 | 
			
		||||
# v13.3.0
 | 
			
		||||
 | 
			
		||||
- Copy cookies from polling to WebSockets ([#1057](https://github.com/socketio/socket.io-client-swift/issues/1057), [#1058](https://github.com/socketio/socket.io-client-swift/issues/1058))
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
Pod::Spec.new do |s|
 | 
			
		||||
  s.name         = "Socket.IO-Client-Swift"
 | 
			
		||||
  s.module_name  = "SocketIO"
 | 
			
		||||
  s.version      = "13.3.0"
 | 
			
		||||
  s.version      = "13.3.1"
 | 
			
		||||
  s.summary      = "Socket.IO-client for iOS and OS X"
 | 
			
		||||
  s.description  = <<-DESC
 | 
			
		||||
                   Socket.IO-client for iOS and OS X.
 | 
			
		||||
@ -18,7 +18,7 @@ Pod::Spec.new do |s|
 | 
			
		||||
  s.requires_arc = true
 | 
			
		||||
  s.source = {
 | 
			
		||||
    :git => "https://github.com/socketio/socket.io-client-swift.git",
 | 
			
		||||
    :tag => 'v13.3.0',
 | 
			
		||||
    :tag => 'v13.3.1',
 | 
			
		||||
    :submodules => true
 | 
			
		||||
  }
 | 
			
		||||
  s.pod_target_xcconfig = {
 | 
			
		||||
 | 
			
		||||
@ -281,7 +281,7 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
 | 
			
		||||
    private func createWebSocketAndConnect() {
 | 
			
		||||
        var req = URLRequest(url: urlWebSocketWithSid)
 | 
			
		||||
 | 
			
		||||
        addHeaders(to: &req, includingCookies: session?.configuration.httpCookieStorage?.cookies)
 | 
			
		||||
        addHeaders(to: &req, includingCookies: session?.configuration.httpCookieStorage?.cookies(for: urlPollingWithSid))
 | 
			
		||||
 | 
			
		||||
        ws = WebSocket(request: req)
 | 
			
		||||
        ws?.callbackQueue = engineQueue
 | 
			
		||||
@ -546,7 +546,7 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
 | 
			
		||||
        pongsMissed += 1
 | 
			
		||||
        write("", withType: .ping, withData: [])
 | 
			
		||||
 | 
			
		||||
        engineQueue.asyncAfter(deadline: DispatchTime.now() + .milliseconds(pingInterval)) {[weak self, id = self.sid] in
 | 
			
		||||
        engineQueue.asyncAfter(deadline: .now() + .milliseconds(pingInterval)) {[weak self, id = self.sid] in
 | 
			
		||||
            // Make sure not to ping old connections
 | 
			
		||||
            guard let this = self, this.sid == id else { return }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -122,9 +122,12 @@ extension SocketEnginePollable {
 | 
			
		||||
 | 
			
		||||
        doRequest(for: req) {[weak self] data, res, err in
 | 
			
		||||
            guard let this = self, this.polling else { return }
 | 
			
		||||
 | 
			
		||||
            if err != nil || data == nil {
 | 
			
		||||
                DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: "SocketEnginePolling")
 | 
			
		||||
            guard let data = data, let res = res as? HTTPURLResponse, res.statusCode == 200 else {
 | 
			
		||||
                if let err = err {
 | 
			
		||||
                    DefaultSocketLogger.Logger.error(err.localizedDescription, type: "SocketEnginePolling")
 | 
			
		||||
                } else {
 | 
			
		||||
                    DefaultSocketLogger.Logger.error("Error during long poll request", type: "SocketEnginePolling")
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if this.polling {
 | 
			
		||||
                    this.didError(reason: err?.localizedDescription ?? "Error")
 | 
			
		||||
@ -135,7 +138,7 @@ extension SocketEnginePollable {
 | 
			
		||||
 | 
			
		||||
            DefaultSocketLogger.Logger.log("Got polling response", type: "SocketEnginePolling")
 | 
			
		||||
 | 
			
		||||
            if let str = String(data: data!, encoding: .utf8) {
 | 
			
		||||
            if let str = String(data: data, encoding: .utf8) {
 | 
			
		||||
                this.parsePollingMessage(str)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -163,11 +166,14 @@ extension SocketEnginePollable {
 | 
			
		||||
 | 
			
		||||
        DefaultSocketLogger.Logger.log("POSTing", type: "SocketEnginePolling")
 | 
			
		||||
 | 
			
		||||
        doRequest(for: req) {[weak self] data, res, err in
 | 
			
		||||
        doRequest(for: req) {[weak self] _, res, err in
 | 
			
		||||
            guard let this = self else { return }
 | 
			
		||||
 | 
			
		||||
            if err != nil {
 | 
			
		||||
                DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: "SocketEnginePolling")
 | 
			
		||||
            guard let res = res as? HTTPURLResponse, res.statusCode == 200 else {
 | 
			
		||||
                if let err = err {
 | 
			
		||||
                    DefaultSocketLogger.Logger.error(err.localizedDescription, type: "SocketEnginePolling")
 | 
			
		||||
                } else {
 | 
			
		||||
                    DefaultSocketLogger.Logger.error("Error flushing waiting posts", type: "SocketEnginePolling")
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if this.polling {
 | 
			
		||||
                    this.didError(reason: err?.localizedDescription ?? "Error")
 | 
			
		||||
 | 
			
		||||
@ -137,10 +137,6 @@ open class SocketManager : NSObject, SocketManagerSpec, SocketParsable, SocketDa
 | 
			
		||||
        self._config = config
 | 
			
		||||
        self.socketURL = socketURL
 | 
			
		||||
 | 
			
		||||
        if socketURL.absoluteString.hasPrefix("https://") {
 | 
			
		||||
            self._config.insert(.secure(true))
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        super.init()
 | 
			
		||||
 | 
			
		||||
        setConfigs(_config)
 | 
			
		||||
@ -489,12 +485,17 @@ open class SocketManager : NSObject, SocketManagerSpec, SocketParsable, SocketDa
 | 
			
		||||
                DefaultSocketLogger.Logger.log = log
 | 
			
		||||
            case let .logger(logger):
 | 
			
		||||
                DefaultSocketLogger.Logger = logger
 | 
			
		||||
            default:
 | 
			
		||||
            case _:
 | 
			
		||||
                continue
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        _config = config
 | 
			
		||||
 | 
			
		||||
        if socketURL.absoluteString.hasPrefix("https://") {
 | 
			
		||||
            _config.insert(.secure(true))
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        _config.insert(.path("/socket.io/"), replacing: false)
 | 
			
		||||
 | 
			
		||||
        // If `ConfigSettable` & `SocketEngineSpec`, update its configs.
 | 
			
		||||
 | 
			
		||||
@ -109,14 +109,11 @@ public extension SocketParsable where Self: SocketManagerSpec & SocketDataBuffer
 | 
			
		||||
        if type == .error {
 | 
			
		||||
            reader.advance(by: -1)
 | 
			
		||||
        } else {
 | 
			
		||||
            while reader.hasNext {
 | 
			
		||||
                if let int = Int(reader.read(count: 1)) {
 | 
			
		||||
                    idString += String(int)
 | 
			
		||||
                } else {
 | 
			
		||||
                    reader.advance(by: -2)
 | 
			
		||||
                    break
 | 
			
		||||
                }
 | 
			
		||||
            while let int = Int(reader.read(count: 1)) {
 | 
			
		||||
                idString += String(int)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            reader.advance(by: -2)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var dataArray = String(message.utf16[message.utf16.index(reader.currentIndex, offsetBy: 1)...])!
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,16 @@ class SocketMangerTest : XCTestCase {
 | 
			
		||||
        XCTAssertEqual(manager.status, .notConnected)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    func testSettingConfig() {
 | 
			
		||||
        let manager = SocketManager(socketURL: URL(string: "https://example.com/")!)
 | 
			
		||||
 | 
			
		||||
        XCTAssertEqual(manager.config.first!, .secure(true))
 | 
			
		||||
 | 
			
		||||
        manager.config = []
 | 
			
		||||
 | 
			
		||||
        XCTAssertEqual(manager.config.first!, .secure(true))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    func testManagerCallsConnect() {
 | 
			
		||||
        setUpSockets()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user