     }
 }
 
-let ResponseDelegateKey = "responseDelegateObject"
+private let ResponseDelegateKey = "responseDelegateObject"
 
 class NetworkOperation: NSOperation {
     

    }
    
    func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData data: NSData) {
        guard let request = dataTask.originalRequest else {
            return
        }
        guard let operation = NSURLProtocol.propertyForKey(ResponseDelegateKey, inRequest: request) as? NetworkOperation else {
            return
        }
        if operation.cancelled {
         operation.finished = true
         dataTask.cancel()
         return
         }
        //As the data may be discontiguous, you should use [NSData enumerateByteRangesUsingBlock:] to access it.
        operation._incomingData.appendData(data)
        
    }
    
    func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) {

        guard let request = task.originalRequest else {
            return
        }
        guard let operation = NSURLProtocol.propertyForKey(ResponseDelegateKey, inRequest: request) as? NetworkOperation else {
            return
        }
        operation.error = error
        operation.finished = true
    }

        
        let request = NSMutableURLRequest(URL: completeURL)
        
        _ = headers?.map { request.setValue($1, forHTTPHeaderField: $0) }
        
        let dataTask = session.dataTaskWithRequest(request)
        dataTask.networkOperation = self
        //NSURLProtocol.setProperty(self, forKey: ResponseDelegateKey, inRequest: request)
        
        dataTask.resume()
    }
    
    private func encodeParameters (parameters: [String: String]) -> String {
        return (parameters.map { "\($0)=\($1)" }).joinWithSeparator("&")
    }
}

extension NSURLSessionTask {
    
    private struct AssociatedKeys {
        static var networkOperation = "networkOperationKey"
    }
    
    var networkOperation: NetworkOperation? {
        get {
            return objc_getAssociatedObject(self, &AssociatedKeys.networkOperation) as? NetworkOperation
        }
        
        set {
            objc_setAssociatedObject(self, &AssociatedKeys.networkOperation, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
}

class ResourceSessionDelegate: NSObject, NSURLSessionDataDelegate {
    
    /*func urlSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: (NSURLSessionResponseDisposition) -> Void) {
        guard let request = dataTask.originalRequest else {
            return
        }
