proxy.expireKey(key);
return true;
}
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.
* Improvement could be to read the error message from a configured
* error file. TODO see how we can combine this method &
* sendresponse method.
*/
outputBuffer.getOutputStream().write(
LoadBalancerProxyConstants.SERVICE_UNAVAILABLE_BYTES);
outputBuffer.endRequest();
outputBuffer.flush();
outputBuffer.commit();
} catch (IOException ex) {
_logger.log(Level.SEVERE, "clb.proxy.http.handler_error_response");
}
}