protected void send503Response(Request request, Response response) {
SocketChannelOutputBuffer outputBuffer = (SocketChannelOutputBuffer) response.getOutputBuffer();
response.setStatus(503);
response.setMessage(
LoadBalancerProxyConstants.SERVICE_UNAVAILABLE);
MimeHeaders headers = response.getMimeHeaders();
headers.setValue(LoadBalancerProxyConstants.HTTP_CONNECTION_HEADER).
setString(LoadBalancerProxyConstants.HTTP_CONNECTION_CLOSE_VALUE);
headers.setValue(LoadBalancerProxyConstants.SERVER_HEADER)
.setString(SelectorThread.SERVER_NAME);
headers.setValue(LoadBalancerProxyConstants.CONTENT_LENGTH_HEADER)
.setInt(
LoadBalancerProxyConstants.SERVICE_UNAVAILABLE_LENGTH);
headers.setValue(LoadBalancerProxyConstants.CONTENT_TYPE_HEADER)
.setString("text/html");
outputBuffer.sendStatus();
int size = headers.size();
for (int i = 0; i < size; i++) {
outputBuffer.sendHeader(headers.getName(i), headers.getValue(i));
}
outputBuffer.endHeaders();
try {
/**Browsers are not happy with the status alone, need to send
* some html message so that it can be displayed to user.