}
@Override
public void handle(Request request, Response response) {
try {
final CiEyeResponse result = responder.respond(request);
response.set("Content-Type", result.contentType);
response.set("Server", "CiEye/1.0 (Simple 4.0)");
response.setDate("Date", result.date);
response.setDate("Last-Modified", result.lastModified);
response.setDate("Expires", result.expires);
response.setContentLength(result.contentLength());
response.setCode(result.status.getCode());
response.setText(result.status.getDescription());
for (Entry<String, String> header : result.additionalStringHeaders.entrySet()) {
response.set(header.getKey(), header.getValue());
}
IOUtils.copy(result.inputStream(), response.getOutputStream());
}
catch (Exception e) {
LOG.error("Failed to respond to request for resource " + request.getPath().getPath(), e);
response.setCode(Status.NOT_FOUND.getCode());
response.setText(Status.NOT_FOUND.getDescription());