   public func deferredDataTask(qos: DispatchQoS = .current,
                                with request: URLRequest) -> DeferredURLSessionTask<(Data, HTTPURLResponse)>
   {
-    let tbd = TBD<(Data, HTTPURLResponse)>(qos: qos)
-
-    let scheme = request.url?.scheme
-    if scheme != "http" && scheme != "https"
-    {
-      let message = "deferred does not support url scheme \"\(scheme ?? "unknown")\""
-      tbd.determine(error: DeferredError.invalid(message))
-    }
-
-    let task = dataTask(with: request, completionHandler: dataCompletion(tbd))
-    return DeferredURLSessionTask(source: tbd, task: task)
+    do { try validateURL(request) }
+    catch {
+      return DeferredURLSessionTask(qos: qos, error: error)
+    }
+
+    return DeferredURLSessionTask(qos: qos) {
+      dataTask(with: request, completionHandler: dataCompletion($0))
+    }
   }
 
   public func deferredDataTask(qos: DispatchQoS = .current,

  case InvalidState
}

public class DeferredURLSessionTask<Value>: Transferred<Value>
{
  public let urlSessionTask: URLSessionTask

  init(source: TBD<Value>, task: URLSessionTask)
  {
    urlSessionTask = task
    super.init(from: source, on: source.queue)
  }

  deinit {
    urlSessionTask.cancel()
  }

  @discardableResult

  public func deferredDownloadTask(qos: DispatchQoS = .current,
                                   withResumeData data: Data) -> DeferredURLSessionTask<(URL, HTTPURLResponse)>
  {
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
    return DeferredDownloadTask(qos: qos) {
      downloadTask(withResumeData: data, completionHandler: downloadCompletion($0))
    }
#else
    // swift-corelibs-foundation calls NSUnimplemented() as the body of downloadTask(withResumeData:)
    // It should instead call the completion handler with URLError.unsupportedURL
    // let task = downloadTask(withResumeData: data, completionHandler: downloadCompletion(tbd))
    let message = "The operation \'\(#function)\' is not supported on this platform"
    let error = URLError(.unsupportedURL, userInfo: [NSLocalizedDescriptionKey: message])
    return DeferredURLSessionTask(qos: qos, error: error)
#endif
  }
}
