}
public void onMessage(IHttpMessage message) throws IOException {
IHttpRequest request = (IHttpRequest) message;
// handle Connection header
handleLifeCycleHeaders(request);
if (LOG.isLoggable(Level.FINE)) {
if (request.getNonBlockingBody() == null) {
LOG.fine("[" + getId() + "] bodyless request received from " + getRemoteAddress() +
":" + getRemotePort() +
" (" + getCountMessagesReceived() + ". request) " + request.getRequestHeader().toString());
} else {
String body = "";
String contentType = request.getContentType();
if ((contentType != null) && (contentType.startsWith("application/x-www-form-urlencode"))) {
body = request.getNonBlockingBody().toString() + "\n";
}
LOG.fine("[" + getId() + "] request received from " + getRemoteAddress() +
":" + getRemotePort() +
" (" + getCountMessagesReceived() + ". request) " + request.getRequestHeader().toString() + body);
}
}
// handle upgrade header
if (isAutohandleUpgadeHeader) {
String upgrade = request.getRequestHeader().getUpgrade();
if ((upgrade != null) && upgrade.equalsIgnoreCase("TLS/1.0")) {
if (getUnderlyingTcpConnection().isSecuredModeActivateable()) {
suspendReceiving();
HttpResponse response = new HttpResponse(101);
response.setHeader("Connection", "Upgrade");
response.setHeader("Upgrade", "TLS/1.0, HTTP/1.1");
writeMessage(response, false);
getUnderlyingTcpConnection().activateSecuredMode();
resumeReceiving();
} else {
send(new HttpResponse(400, "text/html", generateErrorMessageHtml(400, "upgrade TLS is not supported", getId())));
return;
}
return;
}
}
// handle 100 continue header
if (isAutconfirmExpect100ContinueHeader) {
String expectHeader = request.getHeader("Expect");
if ((expectHeader != null) && expectHeader.equalsIgnoreCase("100-Continue")) {
writeMessage(new HttpResponse(100), false);
}
}
if (message.hasBody()) {
if (getBodyDataReceiveTimeoutMillis() != Long.MAX_VALUE) {
message.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(getBodyDataReceiveTimeoutMillis());
}
// is FORM encoded request?
if (isContentTypeFormUrlencoded(request)) {
final IHttpRequest req = request;
IBodyCompleteListener cl = new IBodyCompleteListener() {
@Execution(Execution.NONTHREADED)
public void onComplete() throws IOException {
handleMessage(newFormEncodedRequestWrapper(req));