feat: Set Accept-Patch header.

This commit is contained in:
Ruben Verborgh 2021-01-26 10:30:05 +01:00 committed by Joachim Van Herwegen
parent 394e28b69d
commit 153d2d9fe4
4 changed files with 12 additions and 0 deletions

View File

@ -8,6 +8,10 @@
{ {
"@type": "ConstantMetadataWriter", "@type": "ConstantMetadataWriter",
"ConstantMetadataWriter:_headers": [ "ConstantMetadataWriter:_headers": [
{
"ConstantMetadataWriter:_headers_key": "Accept-Patch",
"ConstantMetadataWriter:_headers_value": "application/sparql-update"
},
{ {
"ConstantMetadataWriter:_headers_key": "MS-Author-Via", "ConstantMetadataWriter:_headers_key": "MS-Author-Via",
"ConstantMetadataWriter:_headers_value": "SPARQL" "ConstantMetadataWriter:_headers_value": "SPARQL"

View File

@ -18,6 +18,7 @@
], ],
"CorsHandler:_options_credentials": true, "CorsHandler:_options_credentials": true,
"CorsHandler:_options_exposedHeaders": [ "CorsHandler:_options_exposedHeaders": [
"Accept-Patch",
"Location", "Location",
"MS-Author-Via", "MS-Author-Via",
"Updates-Via" "Updates-Via"

View File

@ -81,6 +81,7 @@ describe.each(stores)('An LDP handler without auth using %s', (name, { storeUrn,
expect(response.statusCode).toBe(200); expect(response.statusCode).toBe(200);
expect(response._getBuffer().toString()).toContain('TESTFILE0'); expect(response._getBuffer().toString()).toContain('TESTFILE0');
expect(response.getHeaders().link).toBe(`<${LDP.Resource}>; rel="type"`); expect(response.getHeaders().link).toBe(`<${LDP.Resource}>; rel="type"`);
expect(response.getHeaders()['accept-patch']).toBe('application/sparql-update');
expect(response.getHeaders()['ms-author-via']).toBe('SPARQL'); expect(response.getHeaders()['ms-author-via']).toBe('SPARQL');
// DELETE // DELETE

View File

@ -86,6 +86,12 @@ describe('An Express server with middleware', (): void => {
expect(res.header).toEqual(expect.objectContaining({ 'access-control-allow-origin': 'test.com' })); expect(res.header).toEqual(expect.objectContaining({ 'access-control-allow-origin': 'test.com' }));
}); });
it('exposes the Accept-Patch 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');
});
it('exposes the Location header via CORS.', async(): Promise<void> => { it('exposes the Location header via CORS.', async(): Promise<void> => {
const res = await request(server).get('/').expect(200); const res = await request(server).get('/').expect(200);
const exposed = res.header['access-control-expose-headers']; const exposed = res.header['access-control-expose-headers'];