Remove unnecessary this. (#11035)

Motivation:
There are unnecessary `this` keyword usages in `HttpStaticFileServerHandler`.

Modification:
Removed unnecessary `this` keywords.

Result:
Clean code
This commit is contained in:
Aayush Atharva 2021-02-26 16:43:10 +05:30 committed by GitHub
parent dde82f62f0
commit edf44732de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,7 +121,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
}
if (!GET.equals(request.method())) {
this.sendError(ctx, METHOD_NOT_ALLOWED);
sendError(ctx, METHOD_NOT_ALLOWED);
return;
}
@ -129,21 +129,21 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
final String uri = request.uri();
final String path = sanitizeUri(uri);
if (path == null) {
this.sendError(ctx, FORBIDDEN);
sendError(ctx, FORBIDDEN);
return;
}
File file = new File(path);
if (file.isHidden() || !file.exists()) {
this.sendError(ctx, NOT_FOUND);
sendError(ctx, NOT_FOUND);
return;
}
if (file.isDirectory()) {
if (uri.endsWith("/")) {
this.sendListing(ctx, file, uri);
sendListing(ctx, file, uri);
} else {
this.sendRedirect(ctx, uri + '/');
sendRedirect(ctx, uri + '/');
}
return;
}
@ -164,7 +164,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
long ifModifiedSinceDateSeconds = ifModifiedSinceDate.getTime() / 1000;
long fileLastModifiedSeconds = file.lastModified() / 1000;
if (ifModifiedSinceDateSeconds == fileLastModifiedSeconds) {
this.sendNotModified(ctx);
sendNotModified(ctx);
return;
}
}
@ -314,14 +314,14 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK, buffer);
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/html; charset=UTF-8");
this.sendAndCleanupConnection(ctx, response);
sendAndCleanupConnection(ctx, response);
}
private void sendRedirect(ChannelHandlerContext ctx, String newUri) {
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, FOUND, Unpooled.EMPTY_BUFFER);
response.headers().set(HttpHeaderNames.LOCATION, newUri);
this.sendAndCleanupConnection(ctx, response);
sendAndCleanupConnection(ctx, response);
}
private void sendError(ChannelHandlerContext ctx, HttpResponseStatus status) {
@ -329,7 +329,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
HTTP_1_1, status, Unpooled.copiedBuffer("Failure: " + status + "\r\n", CharsetUtil.UTF_8));
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8");
this.sendAndCleanupConnection(ctx, response);
sendAndCleanupConnection(ctx, response);
}
/**
@ -342,7 +342,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, NOT_MODIFIED, Unpooled.EMPTY_BUFFER);
setDateHeader(response);
this.sendAndCleanupConnection(ctx, response);
sendAndCleanupConnection(ctx, response);
}
/**