@Test public void testRemoveTransferEncodingIgnoreCase() { HttpMessage message = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); message.headers().set(HttpHeaderNames.TRANSFER_ENCODING, "Chunked"); assertFalse(message.headers().isEmpty()); HttpUtil.setTransferEncodingChunked(message, false); assertTrue(message.headers().isEmpty()); }
public static void setTransferEncodingChunked(HttpMessage m, boolean chunked) { if (chunked) { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED); m.headers().remove(HttpHeaderNames.CONTENT_LENGTH); } else { List<String> encodings = m.headers().getAll(HttpHeaderNames.TRANSFER_ENCODING); if (encodings.isEmpty()) { return; } List<CharSequence> values = new ArrayList<CharSequence>(encodings); Iterator<CharSequence> valuesIt = values.iterator(); while (valuesIt.hasNext()) { CharSequence value = valuesIt.next(); if (HttpHeaderValues.CHUNKED.contentEqualsIgnoreCase(value)) { valuesIt.remove(); } } if (values.isEmpty()) { m.headers().remove(HttpHeaderNames.TRANSFER_ENCODING); } else { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, values); } } }
HttpUtil { public static void setTransferEncodingChunked(HttpMessage m, boolean chunked) { if (chunked) { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED); m.headers().remove(HttpHeaderNames.CONTENT_LENGTH); } else { List<String> encodings = m.headers().getAll(HttpHeaderNames.TRANSFER_ENCODING); if (encodings.isEmpty()) { return; } List<CharSequence> values = new ArrayList<CharSequence>(encodings); Iterator<CharSequence> valuesIt = values.iterator(); while (valuesIt.hasNext()) { CharSequence value = valuesIt.next(); if (HttpHeaderValues.CHUNKED.contentEqualsIgnoreCase(value)) { valuesIt.remove(); } } if (values.isEmpty()) { m.headers().remove(HttpHeaderNames.TRANSFER_ENCODING); } else { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, values); } } } }
HttpUtil { public static void setTransferEncodingChunked(HttpMessage m, boolean chunked) { if (chunked) { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED); m.headers().remove(HttpHeaderNames.CONTENT_LENGTH); } else { List<String> encodings = m.headers().getAll(HttpHeaderNames.TRANSFER_ENCODING); if (encodings.isEmpty()) { return; } List<CharSequence> values = new ArrayList<CharSequence>(encodings); Iterator<CharSequence> valuesIt = values.iterator(); while (valuesIt.hasNext()) { CharSequence value = valuesIt.next(); if (HttpHeaderValues.CHUNKED.contentEqualsIgnoreCase(value)) { valuesIt.remove(); } } if (values.isEmpty()) { m.headers().remove(HttpHeaderNames.TRANSFER_ENCODING); } else { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, values); } } } private  HttpUtil(); }
HttpUtil { public static void setTransferEncodingChunked(HttpMessage m, boolean chunked) { if (chunked) { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED); m.headers().remove(HttpHeaderNames.CONTENT_LENGTH); } else { List<String> encodings = m.headers().getAll(HttpHeaderNames.TRANSFER_ENCODING); if (encodings.isEmpty()) { return; } List<CharSequence> values = new ArrayList<CharSequence>(encodings); Iterator<CharSequence> valuesIt = values.iterator(); while (valuesIt.hasNext()) { CharSequence value = valuesIt.next(); if (HttpHeaderValues.CHUNKED.contentEqualsIgnoreCase(value)) { valuesIt.remove(); } } if (values.isEmpty()) { m.headers().remove(HttpHeaderNames.TRANSFER_ENCODING); } else { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, values); } } } 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 void setTransferEncodingChunked(HttpMessage m, boolean chunked) { if (chunked) { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED); m.headers().remove(HttpHeaderNames.CONTENT_LENGTH); } else { List<String> encodings = m.headers().getAll(HttpHeaderNames.TRANSFER_ENCODING); if (encodings.isEmpty()) { return; } List<CharSequence> values = new ArrayList<CharSequence>(encodings); Iterator<CharSequence> valuesIt = values.iterator(); while (valuesIt.hasNext()) { CharSequence value = valuesIt.next(); if (HttpHeaderValues.CHUNKED.contentEqualsIgnoreCase(value)) { valuesIt.remove(); } } if (values.isEmpty()) { m.headers().remove(HttpHeaderNames.TRANSFER_ENCODING); } else { m.headers().set(HttpHeaderNames.TRANSFER_ENCODING, values); } } } 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);  }