protected HttpEntity prepareInput(final HttpMessage message) throws HttpException { final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4(); final long len = this.incomingContentStrategy.determineLength(message); final InputStream instream = createInputStream(len, this.inbuffer); if (len == ContentLengthStrategy.CHUNKED) { entity.setChunked(true); entity.setContentLength(-1); entity.setContent(instream); } else if (len == ContentLengthStrategy.IDENTITY) { entity.setChunked(false); entity.setContentLength(-1); entity.setContent(instream); } else { entity.setChunked(false); entity.setContentLength(len); entity.setContent(instream); } final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE); if (contentTypeHeader != null) { entity.setContentType(contentTypeHeader); } final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING); if (contentEncodingHeader != null) { entity.setContentEncoding(contentEncodingHeader); } return entity; }