                 case 400 ..< 500:
                     // reuqest error
                     TUSClient.shared.logger.log(forLevel: .Error, withMessage: String(format: "Received request failure status code %u", httpResponse.statusCode))
-                    markAsFailed(upload: upload, error: nil)
+                    self.markAsFailed(upload: upload, completion: completion, error: nil)
                 case 500 ..< 600:
                     // server
                     TUSClient.shared.logger.log(forLevel: .Error, withMessage: String(format: "Received server failure status code %u", httpResponse.statusCode))
-                    markAsFailed(upload: upload, error: nil)
+                    self.markAsFailed(upload: upload, completion: completion, error: nil)
                 default: break
                 }
             } else {
                 TUSClient.shared.logger.log(forLevel: .Error, withMessage: "Server response couldn't be parsed!")
-                markAsFailed(upload: upload, error: nil)
+                self.markAsFailed(upload: upload, completion: completion, error: nil)
             }
         })
         pendingUploadTasks[upload.id] = task

    ///
    private func prepareUpload(
        forUpload upload: TUSUpload,
        callback: @escaping ([Data], Bool) -> Void
    ) {
        /*


    private func upload(forChunks chunks: [Data], withUpload upload: TUSUpload, atPosition position: Int, completion: @escaping (Bool) -> Void) -> URLSessionUploadTask {
        TUSClient.shared.logger.log(forLevel: .Info, withMessage: String(format: "Upload starting for file %@ - Chunk %u / %u", upload.id, position + 1, chunks.count))

        
        let request: URLRequest = urlRequest(withFullURL: upload.uploadLocationURL!, andMethod: "PATCH", andContentLength: upload.contentLength!, andUploadLength: nil, andFilename: upload.getUploadFilename(), andHeaders: ["Content-Type": "application/offset+octet-stream", "Upload-Offset": upload.uploadOffset!, "Content-Length": String(chunks[position].count), "Upload-Metadata": upload.encodedMetadata])
