Skip to content

Commit

Permalink
update HttpRequestHandler#handlerResources getResource
Browse files Browse the repository at this point in the history
  • Loading branch information
flzj-kl committed Oct 18, 2024
1 parent 7d8cad9 commit cd87438
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -20,7 +21,7 @@
public class HttpResourcesHandler {

private static final Logger logger = LoggerFactory.getLogger(HttpResourcesHandler.class);
private static final String RESOURCES_BASE_PATH = "native-agent/";
private static final String RESOURCES_BASE_PATH = "/native-agent";
private static final Set<String> ALLOWED_EXTENSIONS;

static {
Expand All @@ -42,7 +43,11 @@ public FullHttpResponse handlerResources(FullHttpRequest request, String path) {
if (normalizedPath == null) {
return null;
}
try (InputStream is = getClass().getClassLoader().getResourceAsStream(normalizedPath)) {
URL resourceUrl = getClass().getResource(RESOURCES_BASE_PATH + normalizedPath);
if (resourceUrl == null) {
return null;
}
try (InputStream is = resourceUrl.openStream()) {
if (is == null) {
return null;
}
Expand Down Expand Up @@ -86,7 +91,7 @@ private String normalizePath(String path) {
return null;
}

return RESOURCES_BASE_PATH + path;
return path;
}

private String getContentType(String path) {
Expand Down

0 comments on commit cd87438

Please sign in to comment.