/** * Fetch MIME type part from message's Content-Type header as a char sequence. * * @param message entity to fetch Content-Type header from * @return the MIME type as a {@code CharSequence} from message's Content-Type header * or {@code null} if content-type header or MIME type part of this header are not presented * <p/> * "content-type: text/html; charset=utf-8" - "text/html" will be returned <br/> * "content-type: text/html" - "text/html" will be returned <br/> * "content-type: " or no header - {@code null} we be returned */ public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { return getMimeType(contentTypeValue); } else { return null; } }
/** * Fetch MIME type part from message's Content-Type header as a char sequence. * * @param message entity to fetch Content-Type header from * @return the MIME type as a {@code CharSequence} from message's Content-Type header * or {@code null} if content-type header or MIME type part of this header are not presented * <p/> * "content-type: text/html; charset=utf-8" - "text/html" will be returned <br/> * "content-type: text/html" - "text/html" will be returned <br/> * "content-type: " or no header - {@code null} we be returned */ public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { return getMimeType(contentTypeValue); } else { return null; } }
/** * Fetch MIME type part from message's Content-Type header as a char sequence. * * @param message entity to fetch Content-Type header from * @return the MIME type as a {@code CharSequence} from message's Content-Type header * or {@code null} if content-type header or MIME type part of this header are not presented * <p/> * "content-type: text/html; charset=utf-8" - "text/html" will be returned <br/> * "content-type: text/html" - "text/html" will be returned <br/> * "content-type: " or no header - {@code null} we be returned */ public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { return getMimeType(contentTypeValue); } else { return null; } }
private Optional<String> parseMsg(String contentType, InputStream in) { if (contentType == null || in == null) { return Optional.empty(); } final String mimeType = HttpUtil.getMimeType(contentType).toString(); final Charset encoding = HttpUtil.getCharset(contentType, StandardCharsets.UTF_8); if (APPLICATION_JSON.equalsIgnoreCase(mimeType)) { return readJson(in, encoding); } else if (TEXT_XML.equalsIgnoreCase(mimeType) || APPLICATION_XML.equalsIgnoreCase(mimeType)) { return readXml(in, encoding); } return Optional.empty(); }
/** * Fetch MIME type part from message's Content-Type header as a char sequence. * * @param message entity to fetch Content-Type header from * @return the MIME type as a {@code CharSequence} from message's Content-Type header * or {@code null} if content-type header or MIME type part of this header are not presented * <p/> * "content-type: text/html; charset=utf-8" - "text/html" will be returned <br/> * "content-type: text/html" - "text/html" will be returned <br/> * "content-type: " or no header - {@code null} we be returned */ public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { return getMimeType(contentTypeValue); } else { return null; } }
/** * Fetch MIME type part from message's Content-Type header as a char sequence. * * @param message entity to fetch Content-Type header from * @return the MIME type as a {@code CharSequence} from message's Content-Type header * or {@code null} if content-type header or MIME type part of this header are not presented * <p/> * "content-type: text/html; charset=utf-8" - "text/html" will be returned <br/> * "content-type: text/html" - "text/html" will be returned <br/> * "content-type: " or no header - {@code null} we be returned */ public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { return getMimeType(contentTypeValue); } else { return null; } }
Event e = Event.emptyEvent(Http.this.getConnectionContext(ctx, null)); try { String mimeType = Optional.ofNullable(HttpUtil.getMimeType(request)).orElse("application/octet-stream").toString(); CharSequence encoding = Optional.ofNullable(HttpUtil.getCharsetAsSequence(request)).orElse("UTF-8"); if (request.method() == HttpMethod.GET) {
CharSequence contentType = HttpUtil.getMimeType(req); if (HttpPostRequestDecoder.isMultipart(req) || HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED.contentEqualsIgnoreCase(