@Test public void testGetContentLengthIntDefaultValueThrowsNumberFormatException() { final HttpMessage message = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); message.headers().set(HttpHeaderNames.CONTENT_LENGTH, "bar"); try { HttpUtil.getContentLength(message, 1); fail(); } catch (final NumberFormatException e) { } }
public static long getContentLength(HttpMessage message) { String value = message.headers().get(HttpHeaderNames.CONTENT_LENGTH); if (value != null) { return Long.parseLong(value); } long webSocketContentLength = getWebSocketContentLength(message); if (webSocketContentLength >= 0) { return webSocketContentLength; } throw new NumberFormatException("header not found: " + HttpHeaderNames.CONTENT_LENGTH); }
HttpUtil { public static long getContentLength(HttpMessage message) { String value = message.headers().get(HttpHeaderNames.CONTENT_LENGTH); if (value != null) { return Long.parseLong(value); } long webSocketContentLength = getWebSocketContentLength(message); if (webSocketContentLength >= 0) { return webSocketContentLength; } throw new NumberFormatException("header not found: " + HttpHeaderNames.CONTENT_LENGTH); } }
HttpUtil { public static long getContentLength(HttpMessage message) { String value = message.headers().get(HttpHeaderNames.CONTENT_LENGTH); if (value != null) { return Long.parseLong(value); } long webSocketContentLength = getWebSocketContentLength(message); if (webSocketContentLength >= 0) { return webSocketContentLength; } throw new NumberFormatException("header not found: " + HttpHeaderNames.CONTENT_LENGTH); } private  HttpUtil(); }
HttpUtil { public static long getContentLength(HttpMessage message) { String value = message.headers().get(HttpHeaderNames.CONTENT_LENGTH); if (value != null) { return Long.parseLong(value); } long webSocketContentLength = getWebSocketContentLength(message); if (webSocketContentLength >= 0) { return webSocketContentLength; } throw new NumberFormatException("header not found: " + HttpHeaderNames.CONTENT_LENGTH); } 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(CharSequence contentTypeValue); static Charset getCharset(HttpMessage message, Charset defaultCharset); static Charset getCharset(CharSequence contentTypeValue, Charset defaultCharset); @Deprecated static CharSequence getCharsetAsString(HttpMessage message); static CharSequence getCharsetAsSequence(HttpMessage message); static CharSequence getCharsetAsSequence(CharSequence contentTypeValue); static CharSequence getMimeType(HttpMessage message); static CharSequence getMimeType(CharSequence contentTypeValue); static String formatHostnameForHttp(InetSocketAddress addr); }
HttpUtil { public static long getContentLength(HttpMessage message) { String value = message.headers().get(HttpHeaderNames.CONTENT_LENGTH); if (value != null) { return Long.parseLong(value); } long webSocketContentLength = getWebSocketContentLength(message); if (webSocketContentLength >= 0) { return webSocketContentLength; } throw new NumberFormatException("header not found: " + HttpHeaderNames.CONTENT_LENGTH); } 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(CharSequence contentTypeValue); static Charset getCharset(HttpMessage message, Charset defaultCharset); static Charset getCharset(CharSequence contentTypeValue, Charset defaultCharset); @Deprecated static CharSequence getCharsetAsString(HttpMessage message); static CharSequence getCharsetAsSequence(HttpMessage message); static CharSequence getCharsetAsSequence(CharSequence contentTypeValue); static CharSequence getMimeType(HttpMessage message); static CharSequence getMimeType(CharSequence contentTypeValue); static String formatHostnameForHttp(InetSocketAddress addr);  }