use of core.framework.web.Response in project core-ng-project by neowu.
the class StaticFileController method execute.
@Override
public Response execute(Request request) {
logger.debug("requestFile={}", contentFile);
Response response = Response.file(contentFile);
if (contentType != null)
response.contentType(contentType);
if (cacheHeader != null)
response.header(HTTPHeaders.CACHE_CONTROL, cacheHeader);
return response;
}
use of core.framework.web.Response in project core-ng-project by neowu.
the class WebSecurityInterceptor method intercept.
@Override
public Response intercept(Invocation invocation) throws Exception {
Request request = invocation.context().request();
if (!"https".equals(request.scheme())) {
return Response.redirect(redirectURL(request), HTTPStatus.MOVED_PERMANENTLY);
} else {
Response response = invocation.proceed();
response.header("Strict-Transport-Security", "max-age=31536000");
response.contentType().ifPresent(contentType -> {
if (ContentType.TEXT_HTML.mediaType().equals(contentType.mediaType())) {
response.header("X-Frame-Options", "DENY");
response.header("X-XSS-Protection", "1; mode=block");
}
response.header("X-Content-Type-Options", "nosniff");
});
return response;
}
}
use of core.framework.web.Response in project core-ng-project by neowu.
the class StaticDirectoryController method execute.
@Override
public Response execute(Request request) {
String path = request.pathParam("path");
Path filePath = contentDirectory.resolve(path);
logger.debug("requestFile={}", filePath);
if (!Files.isRegularFile(filePath, LinkOption.NOFOLLOW_LINKS) || !filePath.startsWith(contentDirectory))
throw new NotFoundException("not found, path=" + request.path());
Response response = Response.file(filePath);
ContentType contentType = MimeTypes.get(filePath.getFileName().toString());
if (contentType != null)
response.contentType(contentType);
if (cacheHeader != null)
response.header(HTTPHeaders.CACHE_CONTROL, cacheHeader);
return response;
}
Aggregations