requestHeader.setBodyDefaultEncoding(httpConnection.getBodyDefaultEncoding());
httpConnection.setLastTimeHeaderReceivedMillis(System.currentTimeMillis());
httpConnection.incCountMessageReceived();
IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
if (messageHeaderHandler == null) {
throw new IOException("no message handler set");
}
HttpRequest request = null;
switch (getBodyType(requestHeader)) {
case BODY_TYPE_EMTPY:
request = new HttpRequest(requestHeader);
IMessageHandler messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
messageHandler.onMessageReceived();
rawData = HttpUtils.compact(rawData);
reset();
// next request? (-> pipelining)
if (rawData != null) {
return onData(httpConnection, rawData);
}
break;
case FULL_MESSAGE:
AbstractNetworkBodyDataSource dataSource = new FullMessageBodyDataSource(requestHeader, httpConnection);
setBodyDataSource(dataSource);
request = new HttpRequest(requestHeader, dataSource);
messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
setMessageHandler(messageHandler);
setState(RECEIVING_BODY);
request.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
return parserBody(httpConnection, rawData);
default: // BODY_TYPE_CHUNKED
dataSource = new FullMessageChunkedBodyDataSource(httpConnection, requestHeader);
setBodyDataSource(dataSource);
request = new HttpRequest(requestHeader, dataSource);
messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
setMessageHandler(messageHandler);
setState(RECEIVING_BODY);
request.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());