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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user