Skip to content

Commit

Permalink
Improve handling of HTTP imports
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed Oct 1, 2022
1 parent a1b2736 commit 5262f7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ allprojects {
showCauses true
showStackTraces true
}
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}

afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,18 @@ protected boolean isFile(URL url) throws IOException {
} catch (FileNotFoundException e) {
return false;
}
}
else if (connection instanceof HttpURLConnection) {
try (InputStream in = connection.getInputStream()) {
String contentType = connection.getContentType();

if (urlPath.lastIndexOf("/") > urlPath.lastIndexOf(".")) {
if (!contentType.startsWith("text/")) {
return false;
}
if (contentType.startsWith("text/html")) {
return false;
}
}
} else if (connection instanceof HttpURLConnection) {
HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
httpURLConnection.setRequestMethod("HEAD");

} catch (FileNotFoundException e) {
int responseCode = httpURLConnection.getResponseCode();
if (responseCode > 400) {
return false;
}
if (responseCode == 200) {
return true;
}

}

if (urlPath.endsWith(".css") || urlPath.endsWith(".scss") || urlPath.endsWith(".sass")) {
Expand Down

0 comments on commit 5262f7d

Please sign in to comment.