Source:
private State readHeaders(ByteBuf buffer) { final HttpMessage message = this.message; final HttpHeaders headers = message.headers(); AppendableCharSequence line = headerParser.parse(buffer); if (line == null) { return null; } if (line.length() > 0) { do { char firstChar = line.charAtUnsafe(0); if (name != null && (firstChar == ' ' || firstChar == '\t')) { String trimmedLine = line.toString().trim(); String valueStr = String.valueOf(value); value = valueStr + ' ' + trimmedLine; } else { if (name != null) { headers.add(name, value); } splitHeader(line); } line = headerParser.parse(buffer); if (line == null) { return null; } } while (line.length() > 0); } if (name != null) { headers.add(name, value); } name = null; value = null; List<String> values = headers.getAll(HttpHeaderNames.CONTENT_LENGTH); int size = values.size(); if (size > 0) { contentLength = Long.parseLong(values.get(0)); if (message.protocolVersion() == HttpVersion.HTTP_1_1) { if (size > 1) { throw new IllegalArgumentException("Multiple Content-Length headers found"); } } } if (isContentAlwaysEmpty(message)) { HttpUtil.setTransferEncodingChunked(message, false); return State.SKIP_CONTROL_CHARS; } else if (HttpUtil.isTransferEncodingChunked(message)) { if (message.protocolVersion() == HttpVersion.HTTP_1_1 && size > 0) { throw new IllegalArgumentException( "'Content-Length: " + contentLength + "' and 'Transfer-Encoding: chunked' found"); } return State.READ_CHUNK_SIZE; } else if (contentLength() >= 0) { return State.READ_FIXED_LENGTH_CONTENT; } else { return State.READ_VARIABLE_LENGTH_CONTENT; } }

Target:
private State readHeaders(ByteBuf buffer) { final HttpMessage message = this.message; final HttpHeaders headers = message.headers(); AppendableCharSequence line = headerParser.parse(buffer); if (line == null) { return null; } if (line.length() > 0) { do { char firstChar = line.charAtUnsafe(0); if (name != null && (firstChar == ' ' || firstChar == '\t')) { String trimmedLine = line.toString().trim(); String valueStr = String.valueOf(value); value = valueStr + ' ' + trimmedLine; } else { if (name != null) { headers.add(name, value); } splitHeader(line); } line = headerParser.parse(buffer); if (line == null) { return null; } } while (line.length() > 0); } if (name != null) { headers.add(name, value); } name = null; value = null; List<String> values = headers.getAll(HttpHeaderNames.CONTENT_LENGTH); int contentLengthValuesCount = values.size(); if (contentLengthValuesCount > 0) { if (contentLengthValuesCount > 1 && message.protocolVersion() == HttpVersion.HTTP_1_1) { throw new IllegalArgumentException("Multiple Content-Length headers found"); } contentLength = Long.parseLong(values.get(0)); } if (isContentAlwaysEmpty(message)) { HttpUtil.setTransferEncodingChunked(message, false); return State.SKIP_CONTROL_CHARS; } else if (HttpUtil.isTransferEncodingChunked(message)) { if (contentLengthValuesCount > 0 && message.protocolVersion() == HttpVersion.HTTP_1_1) { throw new IllegalArgumentException( "Both 'Content-Length: " + contentLength + "' and 'Transfer-Encoding: chunked' found"); } return State.READ_CHUNK_SIZE; } else if (contentLength() >= 0) { return State.READ_FIXED_LENGTH_CONTENT; } else { return State.READ_VARIABLE_LENGTH_CONTENT; } }