Merge pull request #28534 from fabiojvalente/feature/pull-gitlab-artifacts-on-refresh
(gitlab integration fix) Do not send If-None-Match and If-Modified-Since for gitlab artifacts urls
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-defaults': patch
|
||||
---
|
||||
|
||||
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