docs: private String calculateHttpEncoding(final String cTMime, final String cTEnc, final String bomEnc, final String xmlGuessEnc, final String xmlEnc,
              final InputStream is, final boolean lenient) throws IOException {
          String encoding;
          if (lenient && xmlEnc != null) {
              encoding = xmlEnc;
          } else {
              final boolean appXml = isAppXml(cTMime);
              final boolean textXml = isTextXml(cTMime);
              if (appXml || textXml) {
                  if (cTEnc == null) {
                      if (appXml) {
                          encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, is);
                      } else {
                          if (defaultEncoding == null) {
                              encoding = US_ASCII;
                          } else {
                              encoding = defaultEncoding;
                          }
                      }
                  } else if (bomEnc != null && (cTEnc.equals(UTF_16BE) || cTEnc.equals(UTF_16LE))) {
                      throw new XmlReaderException(HTTP_EX_1.format(new Object[] { cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc }), cTMime, cTEnc, bomEnc,
                              xmlGuessEnc, xmlEnc, is);
                  } else if (cTEnc.equals(UTF_16)) {
                      if (bomEnc != null && bomEnc.startsWith(UTF_16)) {
                          encoding = bomEnc;
                      } else {
                          throw new XmlReaderException(HTTP_EX_2.format(new Object[] { cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc }), cTMime, cTEnc, bomEnc,
                                  xmlGuessEnc, xmlEnc, is);
                      }
                  } else {
                      encoding = cTEnc;
                  }
              } else {
                  throw new XmlReaderException(HTTP_EX_3.format(new Object[] { cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc }), cTMime, cTEnc, bomEnc, xmlGuessEnc,
                          xmlEnc, is);
              }
          }
          return encoding;
      }