setState(RECEIVING_BODY);
parserBody(rawData);
IMessageHandler messageHandler = httpConnection.getMessageHandler();
if (messageHandler == null) {
throw new IOException("no message handler set");
}
messageHandler.onMessage(response);
return;
}
if (responseHeader != null) {
httpConnection.setLastTimeHeaderReceivedMillis(System.currentTimeMillis());
httpConnection.incCountMessageReceived();
IMessageHandler messageHandler = httpConnection.getMessageHandler();
if (messageHandler == null) {
throw new IOException("no message handler set");
}
try {
HttpResponse response = null;
switch (getBodyType(httpConnection, responseHeader, messageHandler.isBodylessMessageExpected())) {
case BODY_TYPE_EMTPY:
response = new HttpResponse(responseHeader);
reset();
break;
case BODY_TYPE_BOUND:
setBodyParser(new FullMessageBodyParser(httpConnection, responseHeader));
response = new HttpResponse(responseHeader);
response.setBodyDataSourceSilence(getBodyParser().getDataSource());
setState(RECEIVING_BODY);
response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
parserBody(rawData);
break;
case BODY_TYPE_SIMPLE:
setBodyParser(new SimpleMessageBodyParser(httpConnection, responseHeader));
response = new HttpResponse(responseHeader);
response.setBodyDataSourceSilence(getBodyParser().getDataSource());
setState(RECEIVING_BODY);
response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
parserBody(rawData);
break;
case BODY_TYPE_MULTIPART_BYTERANGE:
setBodyParser(new MultipartByteRangeMessageBodyParser(httpConnection, responseHeader));
response = new HttpResponse(responseHeader);
response.setBodyDataSourceSilence(getBodyParser().getDataSource());
setState(RECEIVING_BODY);
response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
parserBody(rawData);
break;
default: // BODY_TYPE_CHUNKED
setBodyParser(new FullMessageChunkedBodyParser(httpConnection, responseHeader));
response = new HttpResponse(responseHeader);
response.setBodyDataSourceSilence(getBodyParser().getDataSource());
setState(RECEIVING_BODY);
response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
parserBody(rawData);
break;
}
messageHandler.onMessage(response);
return;
} catch (BadMessageException bme) {
throw bme;
} catch (IOException ioe) {
messageHandler.onException(ioe);
throw ioe;
}
}
}