         return nil
     }
 
-    private static func encodingFromBOM(prefix: EncodingBytePrefix) -> (encoding: Encoding?, length: Int?) {
+    private static func encodingFromBOM(prefix: EncodingBytePrefix) -> (encoding: Encoding, length: Int)? {
         switch prefix {
         case(0xFE, 0xFF, _, _):
             return (.UTF16BE, 2)


    static func byteOrderMarkLength(header: Slice<UnsafeBufferPointer<UInt8>>) -> Int {
        guard let prefix = prefixFromHeader(header),
            bomLength = encodingFromBOM(prefix).length else {
            return 0
        }
        return bomLength

            return .UTF8
        }

        if let encoding = JSONEncodingDetector.encodingFromBOM(prefix)?.encoding {
            return encoding
        } else {
            switch prefix {
