/** * Creates a new instance of {@link ContentType}. * * @param mimeType MIME type. It may not be {@code null} or empty. It may not contain * characters {@code <">, <;>, <,>} reserved by the HTTP specification. * @param charset charset. * @return content type */ public static ContentType create(final String mimeType, final Charset charset) { final String normalizedMimeType = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.ROOT); Args.check(valid(normalizedMimeType), "MIME type may not contain reserved characters"); return new ContentType(normalizedMimeType, charset); }
/** * Creates a new instance of {@link ContentType}. * * @param mimeType MIME type. It may not be {@code null} or empty. It may not contain * characters {@code <">, <;>, <,>} reserved by the HTTP specification. * @param charset charset. * @return content type */ public static ContentType create(final String mimeType, final Charset charset) { final String normalizedMimeType = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.ROOT); Args.check(valid(normalizedMimeType), "MIME type may not contain reserved characters"); return new ContentType(normalizedMimeType, charset); }
private static ContentType create(final String mimeType, final NameValuePair[] params, final boolean strict) { Charset charset = null; if (params != null) { for (final NameValuePair param : params) { if (param.getName().equalsIgnoreCase("charset")) { final String s = param.getValue(); if (!TextUtils.isBlank(s)) { try { charset = Charset.forName(s); } catch (final UnsupportedCharsetException ex) { if (strict) { throw ex; } } } break; } } } return new ContentType(mimeType, charset, params != null && params.length > 0 ? params : null); }
private static ContentType create(final String mimeType, final NameValuePair[] params, final boolean strict) { Charset charset = null; if (params != null) { for (final NameValuePair param : params) { if (param.getName().equalsIgnoreCase("charset")) { final String s = param.getValue(); if (!TextUtils.isBlank(s)) { try { charset = Charset.forName(s); } catch (final UnsupportedCharsetException ex) { if (strict) { throw ex; } } } break; } } } return new ContentType(mimeType, charset, params != null && params.length > 0 ? params : null); }