boolean forceSuspend = false;
boolean aggregateBodyInMemory = config.aggregateRequestBodyInMemory();
try {
if (messageEvent.getMessage() instanceof HttpRequest) {
final HttpRequest hrequest = (HttpRequest) messageEvent.getMessage();
boolean ka = HttpHeaders.isKeepAlive(hrequest);
asyncWriter = config.supportChunking() ?
new ChunkedWriter(ctx.getChannel(), true, ka, channelBufferPool) :
new StreamWriter(ctx.getChannel(), true, ka);
method = hrequest.getMethod().getName();
// First let's try to see if it's a static resources
if (!hrequest.getUri().contains(HeaderConfig.X_ATMOSPHERE)) {
try {
hrequest.headers().add(STATIC_MAPPING, "true");
super.messageReceived(ctx, messageEvent);
if (HttpHeaders.getHeader(hrequest, SERVICED) != null) {
return;
}
} catch (Exception e) {
logger.debug("Unexpected State", e);
} finally {
hrequest.headers().set(STATIC_MAPPING, "false");
}
}
request = createAtmosphereRequest(ctx, hrequest);
request.setAttribute(KEEP_ALIVE, new Boolean(ka));
// Hacky. Is the POST doesn't contains a body, we must not close the connection yet.
AtmosphereRequest.Body b = request.body();
if (!aggregateBodyInMemory
&& !hrequest.getMethod().equals(GET)
&& !b.isEmpty()
&& (b.hasString() && b.asString().isEmpty())
|| (b.hasBytes() && b.asBytes().length == 0)) {
forceSuspend = true;
}