diff --git a/lib/handlers/patch.js b/lib/handlers/patch.js index 04bcba1e..481027fd 100644 --- a/lib/handlers/patch.js +++ b/lib/handlers/patch.js @@ -91,8 +91,8 @@ async function patchHandler (req, res, next) { return writeGraph(graph, resource, ldp.resourceMapper.resolveFilePath(req.hostname), ldp.serverUri) }) - // Send the result to the client - res.sendStatus(resourceExists ? 200 : 201) + // Send the status and result to the client + res.status(resourceExists ? 200 : 201) res.send(result) } catch (err) { return next(err) diff --git a/test/integration/acl-oidc-test.js b/test/integration/acl-oidc-test.js index 77919a35..a5a31270 100644 --- a/test/integration/acl-oidc-test.js +++ b/test/integration/acl-oidc-test.js @@ -557,7 +557,7 @@ describe('ACL with WebID+OIDC over HTTP', function () { options.headers['content-type'] = 'application/sparql-update' request.patch(options, function (error, response, body) { assert.equal(error, null) - assert.equal(response.statusCode, 200) + assert.equal(response.statusCode, 201) done() }) }) @@ -616,7 +616,7 @@ describe('ACL with WebID+OIDC over HTTP', function () { options.headers['content-type'] = 'application/sparql-update' request.patch(options, function (error, response, body) { assert.equal(error, null) - assert.equal(response.statusCode, 200) + assert.equal(response.statusCode, 201) done() }) }) diff --git a/test/integration/patch-sparql-update-test.js b/test/integration/patch-sparql-update-test.js index 3e8a1ad2..69ea9b01 100644 --- a/test/integration/patch-sparql-update-test.js +++ b/test/integration/patch-sparql-update-test.js @@ -22,7 +22,7 @@ describe('PATCH through application/sparql-update', function () { server.patch('/notExisting.ttl') .set('content-type', 'application/sparql-update') .send('INSERT DATA { :test :hello 456 .}') - .expect(200) + .expect(201) .end(function (err, res, body) { assert.equal( read('sampleContainer/notExisting.ttl'), diff --git a/test/integration/patch-test.js b/test/integration/patch-test.js index 846f0480..9d3d6f13 100644 --- a/test/integration/patch-test.js +++ b/test/integration/patch-test.js @@ -79,7 +79,7 @@ describe('PATCH through text/n3', () => { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { // expected: - status: 200, + status: 201, text: 'Patch applied successfully', result: '@prefix : .\n@prefix tim: .\n\ntim:x tim:y tim:z.\n\n' })) @@ -90,7 +90,7 @@ describe('PATCH through text/n3', () => { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { // expected: - status: 200, + status: 201, text: 'Patch applied successfully', // result: '{\n "@id": "/x",\n "/y": {\n "@id": "/z"\n }\n}' result: `{ @@ -110,7 +110,7 @@ describe('PATCH through text/n3', () => { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { // expected: - status: 200, + status: 201, text: 'Patch applied successfully', result: ` { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { // expected: - status: 200, + status: 201, text: 'Patch applied successfully', result: '@prefix : .\n@prefix tim: .\n\ntim:x tim:y tim:z.\n\n' })) @@ -186,7 +186,7 @@ describe('PATCH through text/n3', () => { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { - status: 200, + status: 201, text: 'Patch applied successfully', result: '@prefix : <#>.\n@prefix fol: <./>.\n\nfol:x fol:y fol:z.\n\n' }))