Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,13 @@ class DefaultPackageProvenanceResolver(
}
}

// Try a cheap HEAD request to probe for the artifact first, and only fall back to a GET request on failure.
val responseCode = requestSourceArtifact(pkg, "HEAD").takeUnless { it == HttpURLConnection.HTTP_BAD_METHOD }
// Try a cheap HEAD request to probe for the artifact first, and fall back to a GET request when necessary.
// Some artifact are behind redirected urls, in case of 404 we need to fall back to GET to verify that.
val responseCode = requestSourceArtifact(pkg, "HEAD")
.takeUnless { it == HttpURLConnection.HTTP_BAD_METHOD || it == HttpURLConnection.HTTP_NOT_FOUND }
?: requestSourceArtifact(pkg, "GET")

if (responseCode == HttpURLConnection.HTTP_OK) {
if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {
val artifactProvenance = ArtifactProvenance(pkg.sourceArtifact)
storage.writeProvenance(pkg.id, pkg.sourceArtifact, ResolvedArtifactProvenance(artifactProvenance))
return artifactProvenance
Expand Down
Loading