 		getSessionModel(task.taskIdentifier)?.stateBlock(.begin)
 	}
 }
+
+extension LQDownload: URLSessionDataDelegate {
+	
+	//接收到相应
+	func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
+		
+		guard var sessionModel = getSessionModel(dataTask.taskIdentifier)  else {
+			return
+		}
+		//打开流
+		sessionModel.stream?.open()
+		//获取本次请求 返回数据的总长度
+		let totalLength = response.expectedContentLength + fileDownloadSize(sessionModel.url)
+		
+		sessionModel.totalLength = Int(totalLength)
+		
+		//存储总长度
+		var dict = NSMutableDictionary(contentsOf: URL(fileURLWithPath: totalLengthFullPath()))
+		if dict == nil {
+			dict = NSMutableDictionary()
+		}
+		dict?[fileName(sessionModel.url) ?? "错误URL"] = Int(totalLength)
+		
+		//接受这个请求, 允许接受服务器的数据
+		completionHandler(.allow)
+	}
+	
+	//接受到服务器返回的数据
+	func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
+		
+	}
+	
+	//请求完毕 (成功/失败)
+	func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
+		
+	}
+}

	}
	
	//文件已下载大小
	func fileDownloadSize(_ url: String) -> Int? {
		var filesize: Int?
		do {
			let attr = try FileManager.default.attributesOfItem(atPath: fileFullPath(url))

}

struct LQSessionModel {
	var stream: OutputStream?
	var url: String
	var totalLength: Int
	var progressBlock: (Int, Int, Double) -> Void
