org.webbitserver.handler.DateHeaderHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webbit Show documentation
Show all versions of webbit Show documentation
A Java event based WebSocket and HTTP server
package org.webbitserver.handler;
import org.jboss.netty.handler.codec.http.HttpHeaders;
import org.webbitserver.HttpControl;
import org.webbitserver.HttpHandler;
import org.webbitserver.HttpRequest;
import org.webbitserver.HttpResponse;
import java.util.Date;
/**
* Handler that sets the HTTP 'Server' response header.
*/
public class DateHeaderHandler implements HttpHandler {
@Override
public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control) throws Exception {
if (!response.containsHeader(HttpHeaders.Names.DATE)) {
response.header(HttpHeaders.Names.DATE, new Date());
}
control.nextHandler();
}
}