@Test public void testGetMimeType() { HttpMessage message = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); assertNull(HttpUtil.getMimeType(message)); message.headers().set(HttpHeaderNames.CONTENT_TYPE, ""); assertNull(HttpUtil.getMimeType(message)); message.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/html"); assertEquals("text/html", HttpUtil.getMimeType(message)); message.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/html; charset=utf-8"); assertEquals("text/html", HttpUtil.getMimeType(message)); }
public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, SEMICOLON, 0); if (indexOfSemicolon != AsciiString.INDEX_NOT_FOUND) { return contentTypeValue.subSequence(0, indexOfSemicolon); } else { return contentTypeValue.length() > 0 ? contentTypeValue : null; } } return null; }
HttpUtil { public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, SEMICOLON, 0); if (indexOfSemicolon != AsciiString.INDEX_NOT_FOUND) { return contentTypeValue.subSequence(0, indexOfSemicolon); } else { return contentTypeValue.length() > 0 ? contentTypeValue : null; } } return null; } }
HttpUtil { public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, SEMICOLON, 0); if (indexOfSemicolon != AsciiString.INDEX_NOT_FOUND) { return contentTypeValue.subSequence(0, indexOfSemicolon); } else { return contentTypeValue.length() > 0 ? contentTypeValue : null; } } return null; } private  HttpUtil(); }
HttpUtil { public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, SEMICOLON, 0); if (indexOfSemicolon != AsciiString.INDEX_NOT_FOUND) { return contentTypeValue.subSequence(0, indexOfSemicolon); } else { return contentTypeValue.length() > 0 ? contentTypeValue : null; } } return null; } private  HttpUtil(); static boolean isOriginForm(URI uri); static boolean isAsteriskForm(URI uri); static boolean isKeepAlive(HttpMessage message); static void setKeepAlive(HttpMessage message, boolean keepAlive); static void setKeepAlive(HttpHeaders h, HttpVersion httpVersion, boolean keepAlive); static long getContentLength(HttpMessage message); static long getContentLength(HttpMessage message, long defaultValue); static int getContentLength(HttpMessage message, int defaultValue); static void setContentLength(HttpMessage message, long length); static boolean isContentLengthSet(HttpMessage m); static boolean is100ContinueExpected(HttpMessage message); static void set100ContinueExpected(HttpMessage message, boolean expected); static boolean isTransferEncodingChunked(HttpMessage message); static void setTransferEncodingChunked(HttpMessage m, boolean chunked); static Charset getCharset(HttpMessage message); static Charset getCharset(HttpMessage message, Charset defaultCharset); static CharSequence getCharsetAsString(HttpMessage message); static CharSequence getMimeType(HttpMessage message); }
HttpUtil { public static CharSequence getMimeType(HttpMessage message) { CharSequence contentTypeValue = message.headers().get(HttpHeaderNames.CONTENT_TYPE); if (contentTypeValue != null) { int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, SEMICOLON, 0); if (indexOfSemicolon != AsciiString.INDEX_NOT_FOUND) { return contentTypeValue.subSequence(0, indexOfSemicolon); } else { return contentTypeValue.length() > 0 ? contentTypeValue : null; } } return null; } private  HttpUtil(); static boolean isOriginForm(URI uri); static boolean isAsteriskForm(URI uri); static boolean isKeepAlive(HttpMessage message); static void setKeepAlive(HttpMessage message, boolean keepAlive); static void setKeepAlive(HttpHeaders h, HttpVersion httpVersion, boolean keepAlive); static long getContentLength(HttpMessage message); static long getContentLength(HttpMessage message, long defaultValue); static int getContentLength(HttpMessage message, int defaultValue); static void setContentLength(HttpMessage message, long length); static boolean isContentLengthSet(HttpMessage m); static boolean is100ContinueExpected(HttpMessage message); static void set100ContinueExpected(HttpMessage message, boolean expected); static boolean isTransferEncodingChunked(HttpMessage message); static void setTransferEncodingChunked(HttpMessage m, boolean chunked); static Charset getCharset(HttpMessage message); static Charset getCharset(HttpMessage message, Charset defaultCharset); static CharSequence getCharsetAsString(HttpMessage message); static CharSequence getMimeType(HttpMessage message);  }