 
 ///Parses the http response from a socket that is returning mulitple json messages separated by newlines
 class DockerResponseHandler {
+	let crnl = Data(bytes: [13, 10])
 	private let handler: (MessageType) -> Void
 	private let fileHandle: FileHandle
 	private var readSource: DispatchSourceRead?
 	private var gotHeader = false
 	private var myQueue = DispatchQueue.global()
-	private var leftoverData: Data?
+	private var isChunked: Bool = false
+	private var isHijacked = false
+	private var chunkCount: Int = 0
 	
 	/// Initiailize an instance
 	///
 	/// - Parameters:
 	///   - fileHandle: the source of the data, must have a valid fileDescriptor value
-	init(fileHandle: FileHandle, handler: @escaping (MessageType) -> Void) {
+	init(fileHandle: FileHandle, hijacked: Bool = false, handler: @escaping (MessageType) -> Void) {
 		self.fileHandle = fileHandle
 		self.handler = handler
+		self.isHijacked = hijacked
 	}
 	
 	///chokepoint for logging/debugging

			source.cancel()
			return
		}
		var data = fileHandle.readData(ofLength: Int(sizeRead))
		do {
			guard gotHeader else {
				parseInitialContent(data)
				return
			}
			if leftoverData != nil {
				leftoverData?.append(data)
				data = leftoverData!
				leftoverData = nil
			}
			let (message, remaining) = try parse(data: data)
			leftoverData = remaining
			if let actualMessage = message {
				sendMessage(actualMessage)
			}
		} catch {
			readSource = nil
			sendMessage(.error)
			source.cancel()
		}
	}
	
	/// Parses the input string into individual lines of json, sending them via handler. Returns any remaining text that didn't have a newline at the end
	///
	/// - Parameter data: the data from the socket
	/// - Returns: any remaining data that didn't end with a newline
	/// - Throws: json parse errors
	func parse(data: Data) throws -> (MessageType?, Data?) {
		fatalError("subclass must implement parse()")
	}
	
	private func parseInitialContent(_ data: Data) {
		do {
			let (headData, contentData) = try HttpStringUtils.splitResponseData(data)
			//TODO: confirm 200 response on http status from headData
			let (message, remainingData) = try parse(data: contentData)
			leftoverData = remainingData
			sendMessage(.headers(headData))
			gotHeader = true
			if let actualMessage = message {
				sendMessage(actualMessage)
			}
		} catch {
			leftoverData = data
		}
	}
}

///This class takes a socket that contains the response from a docker api call

enum MessageType: Equatable {
	case headers(HttpHeaders), json([JSON]), data(Data), complete, error(Rc2Error)
	
	static func == (a: MessageType, b: MessageType) -> Bool {
		switch (a, b) {
		case (.error(let e1), .error(let e2)):
			return e1.type == e2.type //FIXME: not correct
		case (.complete, .complete):
			return true
		case (.json(let j1), .json(let j2)):
