Skip to content

Commit

Permalink
feat: Set Accept-Patch header.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh authored and joachimvh committed Jan 26, 2021
1 parent 394e28b commit 153d2d9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/presets/ldp/response-writer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
{
"@type": "ConstantMetadataWriter",
"ConstantMetadataWriter:_headers": [
{
"ConstantMetadataWriter:_headers_key": "Accept-Patch",
"ConstantMetadataWriter:_headers_value": "application/sparql-update"
},
{
"ConstantMetadataWriter:_headers_key": "MS-Author-Via",
"ConstantMetadataWriter:_headers_value": "SPARQL"
Expand Down
1 change: 1 addition & 0 deletions config/presets/middleware.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"CorsHandler:_options_credentials": true,
"CorsHandler:_options_exposedHeaders": [
"Accept-Patch",
"Location",
"MS-Author-Via",
"Updates-Via"
Expand Down
1 change: 1 addition & 0 deletions test/integration/LdpHandlerWithoutAuth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe.each(stores)('An LDP handler without auth using %s', (name, { storeUrn,
expect(response.statusCode).toBe(200);
expect(response._getBuffer().toString()).toContain('TESTFILE0');
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');

// DELETE
Expand Down
6 changes: 6 additions & 0 deletions test/integration/Middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ describe('An Express 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> => {
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> => {
const res = await request(server).get('/').expect(200);
const exposed = res.header['access-control-expose-headers'];
Expand Down

0 comments on commit 153d2d9

Please sign in to comment.