feat: Dynamically generate Allow and Accept-* headers

This commit is contained in:
Joachim Van Herwegen
2022-03-25 11:34:40 +01:00
parent effc20a270
commit 6e98c6aae4
15 changed files with 326 additions and 18 deletions

View File

@@ -93,10 +93,12 @@ describe('An http server with middleware', (): void => {
expect(res.header).toEqual(expect.objectContaining({ 'access-control-allow-origin': 'test.com' }));
});
it('exposes the Accept-Patch header via CORS.', async(): Promise<void> => {
it('exposes the Accept-[Method] header via CORS.', async(): Promise<void> => {
const res = await request(server).get('/').expect(200);
const exposed = res.header['access-control-expose-headers'];
expect(exposed.split(/\s*,\s*/u)).toContain('Accept-Patch');
expect(exposed.split(/\s*,\s*/u)).toContain('Accept-Post');
expect(exposed.split(/\s*,\s*/u)).toContain('Accept-Put');
});
it('exposes the Last-Modified and ETag headers via CORS.', async(): Promise<void> => {