 		return KBAPIConnectionQueue;
 	}
 	
+	private var taskWasCancelled = false;
 	private var taskWrapper: SessionTaskWrapper;
 	
 	open class func withRequest (_ request: Request) -> KBAPIConnection {

import Foundation

public protocol KBAPIConnectionProtocol: AnyObject {
	func cancel ();
}


		fileprivate let request: Request;
		
		fileprivate var task: URLSessionTask {
			guard let taskPointer = self.taskPointer else {
				log.fault ("URL session task is not created yet");
				return URLSessionTask ();
			}
			return taskPointer.pointee;
		}
		
		fileprivate var isTaskValid: Bool {
			return self.taskPointer != nil;
		}
		
		private unowned let session: URLSession;
		private var taskPointer: UnsafePointer <URLSessionTask>?;
		
		fileprivate init (session: URLSession, request: Request) {
			self.session = session;
