mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Support conditions for GET/HEAD requests
* fix: updated WrappedExpiringStorage tests and timer.unref calls * fix: removed finalizable configs and inheritors that only used timer * fix: updated test function to test setSafeInterval and timer.unref * fix: added NotModifiedHttpError class * fix: added 304 error test to HttpError test file * fix: 304 errors when making read request with matching ETag * Update src/util/errors/NotModifiedHttpError.ts Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com> * fix: updated tests * fix: try notMatchesEtag in test * fix: DataAccessorBasedStore test passes * fix: removed conditions check and added extra test --------- Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
This commit is contained in:
@@ -170,6 +170,27 @@ describe.each(stores)('A server supporting conditions with %s', (name, { storeCo
|
||||
expect(await deleteResource(documentUrl!)).toBeUndefined();
|
||||
});
|
||||
|
||||
it('throws 304 error if "if-none-match" header matches and request type is GET or HEAD.', async(): Promise<void> => {
|
||||
// GET root ETag
|
||||
let response = await getResource(baseUrl);
|
||||
const eTag = response.headers.get('ETag');
|
||||
expect(typeof eTag).toBe('string');
|
||||
|
||||
// GET fails because of header
|
||||
response = await fetch(baseUrl, {
|
||||
method: 'GET',
|
||||
headers: { 'if-none-match': eTag! },
|
||||
});
|
||||
expect(response.status).toBe(304);
|
||||
|
||||
// HEAD fails because of header
|
||||
response = await fetch(baseUrl, {
|
||||
method: 'HEAD',
|
||||
headers: { 'if-none-match': eTag! },
|
||||
});
|
||||
expect(response.status).toBe(304);
|
||||
});
|
||||
|
||||
it('prevents operations if the "if-unmodified-since" header is before the modified date.', async(): Promise<void> => {
|
||||
const documentUrl = `${baseUrl}document3.txt`;
|
||||
// PUT
|
||||
|
||||
Reference in New Issue
Block a user