 
 public class TestURLServer: URLProtocol
 {
-  typealias Chunks = [Chunk]
-  typealias Response = (URLRequest) -> (Chunks, HTTPURLResponse)
+  typealias Response = (URLRequest) -> ([Command], HTTPURLResponse)
   static private var testURLs: [URL: Response] = [:]
 
-  public enum Chunk
-  {
-    case data(Data), wait(TimeInterval), fail(Error)
+  public enum Command
+  {
+    case load(Data), wait(TimeInterval), fail(Error), finishLoading
   }
 
   static func register(url: URL, response: @escaping Response)

      headers["ETag"] = "\"" + String(dumbCheckSum, radix: 16) + "\""
      let cut = Int.random(in: (data.count/3...2*(data.count/3)))
      let response = HTTPURLResponse(url: largeURL, statusCode: 200, httpVersion: nil, headerFields: headers)!
      return ([.data(data[0..<cut]), .wait(10.0), .data(data[cut...])], response)
    }
  }


//MARK: requests to missing URLs

let missingURL = baseURL.appendingPathComponent("404")
func missingGET(_ request: URLRequest) -> ([TestURLServer.Command], HTTPURLResponse)
{
  let response = HTTPURLResponse(url: missingURL, statusCode: 404, httpVersion: nil, headerFields: [:])
  XCTAssertNotNil(response)
  return ([.load(Data("Not Found".utf8)), .finishLoading], response!)
}

extension URLSessionTests
