mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Ensure the ETag is representation specific
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { ResourceStore } from '../../storage/ResourceStore';
|
||||
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
|
||||
import { assertReadConditions } from '../../util/ResourceUtil';
|
||||
import { OkResponseDescription } from '../output/response/OkResponseDescription';
|
||||
import type { ResponseDescription } from '../output/response/ResponseDescription';
|
||||
import type { OperationHandlerInput } from './OperationHandler';
|
||||
@@ -26,6 +27,9 @@ export class GetOperationHandler extends OperationHandler {
|
||||
public async handle({ operation }: OperationHandlerInput): Promise<ResponseDescription> {
|
||||
const body = await this.store.getRepresentation(operation.target, operation.preferences, operation.conditions);
|
||||
|
||||
// Check whether the cached representation is still valid or it is necessary to send a new representation
|
||||
assertReadConditions(body, operation.conditions);
|
||||
|
||||
return new OkResponseDescription(body.metadata, body.data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ResourceStore } from '../../storage/ResourceStore';
|
||||
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
|
||||
import { assertReadConditions } from '../../util/ResourceUtil';
|
||||
import { OkResponseDescription } from '../output/response/OkResponseDescription';
|
||||
import type { ResponseDescription } from '../output/response/ResponseDescription';
|
||||
import type { OperationHandlerInput } from './OperationHandler';
|
||||
@@ -29,6 +30,10 @@ export class HeadOperationHandler extends OperationHandler {
|
||||
// Close the Readable as we will not return it.
|
||||
body.data.destroy();
|
||||
|
||||
// Check whether the cached representation is still valid or it is necessary to send a new representation.
|
||||
// Generally it doesn't make much sense to use condition headers with a HEAD request, but it should be supported.
|
||||
assertReadConditions(body, operation.conditions);
|
||||
|
||||
return new OkResponseDescription(body.metadata);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user