Do not use etag or if-modified-since for gitlab artifacts urls

Signed-off-by: Fabio Valente <8777512+fabiojvalente@users.noreply.github.com>
This commit is contained in:
Fabio Valente
2025-01-16 12:26:33 +00:00
committed by blam
parent 1042648095
commit 0d390299ee
2 changed files with 11 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-defaults': minor
---
Do not send etag or If-Modified-Since headers for gitlab artifact urls
@@ -74,6 +74,7 @@ export class GitlabUrlReader implements UrlReaderService {
options?: UrlReaderServiceReadUrlOptions,
): Promise<UrlReaderServiceReadUrlResponse> {
const { etag, lastModifiedAfter, signal, token } = options ?? {};
const isArtifact = url.includes('/-/jobs/artifacts/');
const builtUrl = await this.getGitlabFetchUrl(url);
let response: Response;
@@ -81,10 +82,11 @@ export class GitlabUrlReader implements UrlReaderService {
response = await fetch(builtUrl, {
headers: {
...getGitLabRequestOptions(this.integration.config, token).headers,
...(etag && { 'If-None-Match': etag }),
...(lastModifiedAfter && {
'If-Modified-Since': lastModifiedAfter.toUTCString(),
}),
...(etag && !isArtifact && { 'If-None-Match': etag }),
...(lastModifiedAfter &&
!isArtifact && {
'If-Modified-Since': lastModifiedAfter.toUTCString(),
}),
},
// TODO(freben): The signal cast is there because pre-3.x versions of
// node-fetch have a very slightly deviating AbortSignal type signature.