Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ldp.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class LDP {

// HACK: the middleware in webid-oidc.js uses body-parser, thus ending the stream of data
// for JSON bodies. So, the stream needs to be reset
if (contentType.includes('application/json')) {
if (contentType && contentType.includes('application/json')) {
stream = intoStream(JSON.stringify(stream.body))
}

Expand Down
21 changes: 21 additions & 0 deletions test/integration/http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,27 @@ describe('HTTP APIs', function () {
.expect(hasHeader('acl', suffixAcl))
.expect(201, done)
})
it('should create new resource even if body is empty', function (done) {
server.post('/post-tests/')
.set('slug', 'post-resource-empty')
.set('content-type', 'text/turtle')
.expect(hasHeader('describedBy', suffixMeta))
.expect(hasHeader('acl', suffixAcl))
.expect('location', /.*\.ttl/)
.expect(201, done)
})
it('should error with 415 if the body is empty and no content type is provided', function (done) {
server.post('/post-tests/')
.set('slug', 'post-resource-empty-fail')
.expect(415, done)
})
it('should error with 415 if the body is provided but there is no content-type header', function (done) {
server.post('/post-tests/')
.set('slug', 'post-resource-rdf-no-content-type')
.send(postRequest1Body)
.set('content-type', '')
.expect(415, done)
})
it('should create new resource even if no trailing / is in the target',
function (done) {
server.post('')
Expand Down