mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: etag support RFC 9110 standard (#9077)
ETag must be in double quotes based on standard. Fixing it. ``` If-None-Match: "<etag_value>"
This commit is contained in:
parent
67068afb13
commit
fda2252957
@ -98,7 +98,7 @@ test('should get 304 if asked for latest revision', async () => {
|
|||||||
const currentRevisionId = body.revisionId;
|
const currentRevisionId = body.revisionId;
|
||||||
|
|
||||||
await app.request
|
await app.request
|
||||||
.set('If-None-Match', currentRevisionId)
|
.set('If-None-Match', `"${currentRevisionId}"`)
|
||||||
.get('/api/client/delta')
|
.get('/api/client/delta')
|
||||||
.expect(304);
|
.expect(304);
|
||||||
});
|
});
|
||||||
@ -123,7 +123,7 @@ test('should return correct delta after feature created', async () => {
|
|||||||
|
|
||||||
const { body: deltaBody } = await app.request
|
const { body: deltaBody } = await app.request
|
||||||
.get('/api/client/delta')
|
.get('/api/client/delta')
|
||||||
.set('If-None-Match', currentRevisionId)
|
.set('If-None-Match', `"${currentRevisionId}"`)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
expect(deltaBody).toMatchObject({
|
expect(deltaBody).toMatchObject({
|
||||||
@ -162,7 +162,7 @@ test('archived features should not be returned as updated', async () => {
|
|||||||
|
|
||||||
const { body: deltaBody } = await app.request
|
const { body: deltaBody } = await app.request
|
||||||
.get('/api/client/delta')
|
.get('/api/client/delta')
|
||||||
.set('If-None-Match', currentRevisionId)
|
.set('If-None-Match', `"${currentRevisionId}"`)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
expect(deltaBody).toMatchObject({
|
expect(deltaBody).toMatchObject({
|
||||||
|
@ -85,7 +85,11 @@ export default class ClientFeatureToggleDeltaController extends Controller {
|
|||||||
const query = await this.resolveQuery(req);
|
const query = await this.resolveQuery(req);
|
||||||
const etag = req.headers['if-none-match'];
|
const etag = req.headers['if-none-match'];
|
||||||
|
|
||||||
const currentSdkRevisionId = etag ? Number.parseInt(etag) : undefined;
|
const sanitizedEtag = etag ? etag.replace(/^"(.*)"$/, '$1') : undefined;
|
||||||
|
|
||||||
|
const currentSdkRevisionId = sanitizedEtag
|
||||||
|
? Number.parseInt(sanitizedEtag)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const changedFeatures =
|
const changedFeatures =
|
||||||
await this.clientFeatureToggleService.getClientDelta(
|
await this.clientFeatureToggleService.getClientDelta(
|
||||||
@ -107,7 +111,7 @@ export default class ClientFeatureToggleDeltaController extends Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.setHeader('ETag', changedFeatures.revisionId.toString());
|
res.setHeader('ETag', `"${changedFeatures.revisionId}"`);
|
||||||
this.openApiService.respondWithValidation(
|
this.openApiService.respondWithValidation(
|
||||||
200,
|
200,
|
||||||
res,
|
res,
|
||||||
|
Loading…
Reference in New Issue
Block a user