     public class func cancelRequest<T: Request>(requestType: T.Type, URLSession: NSURLSession, passingTest test: T -> Bool = { r in true }) {
         URLSession.getTasksWithCompletionHandler { dataTasks, uploadTasks, downloadTasks in
             let tasks = (dataTasks + uploadTasks + downloadTasks).filter { task in
-                if let request = (task as? NSURLSessionTask)?.request?.unbox as? T {
+                if let request = (task as? NSURLSessionTask)?.request as? T {
                     return test(request)
                 } else {
                     return false

        if let URLRequest = request.URLRequest {
            let task = URLSession.dataTaskWithRequest(URLRequest)
            
            task.request = Box(request)
            task.completionHandler = { data, URLResponse, connectionError in
                if let error = connectionError {
                    dispatch_async(mainQueue, { handler(.Failure(Box(error))) })

        }
    }

    // `var request: Request?` is not available in both of Swift 1.1 and 1.2
    // ("protocol can only be used as a generic constraint")
    private var request: Any? {
        get {
            return (objc_getAssociatedObject(self, &taskRequestKey) as? Box<Any>)?.unbox
        }
        
        set {
            if let value = newValue {
                objc_setAssociatedObject(self, &taskRequestKey, Box(value), UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
            } else {
                objc_setAssociatedObject(self, &taskRequestKey, nil, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
            }
