File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ class LDP {
158158
159159 // HACK: the middleware in webid-oidc.js uses body-parser, thus ending the stream of data
160160 // for JSON bodies. So, the stream needs to be reset
161- if ( contentType . includes ( 'application/json' ) ) {
161+ if ( contentType && contentType . includes ( 'application/json' ) ) {
162162 stream = intoStream ( JSON . stringify ( stream . body ) )
163163 }
164164
Original file line number Diff line number Diff line change @@ -559,6 +559,27 @@ describe('HTTP APIs', function () {
559559 . expect ( hasHeader ( 'acl' , suffixAcl ) )
560560 . expect ( 201 , done )
561561 } )
562+ it ( 'should create new resource even if body is empty' , function ( done ) {
563+ server . post ( '/post-tests/' )
564+ . set ( 'slug' , 'post-resource-empty' )
565+ . set ( 'content-type' , 'text/turtle' )
566+ . expect ( hasHeader ( 'describedBy' , suffixMeta ) )
567+ . expect ( hasHeader ( 'acl' , suffixAcl ) )
568+ . expect ( 'location' , / .* \. t t l / )
569+ . expect ( 201 , done )
570+ } )
571+ it ( 'should error with 415 if the body is empty and no content type is provided' , function ( done ) {
572+ server . post ( '/post-tests/' )
573+ . set ( 'slug' , 'post-resource-empty-fail' )
574+ . expect ( 415 , done )
575+ } )
576+ it ( 'should error with 415 if the body is provided but there is no content-type header' , function ( done ) {
577+ server . post ( '/post-tests/' )
578+ . set ( 'slug' , 'post-resource-rdf-no-content-type' )
579+ . send ( postRequest1Body )
580+ . set ( 'content-type' , '' )
581+ . expect ( 415 , done )
582+ } )
562583 it ( 'should create new resource even if no trailing / is in the target' ,
563584 function ( done ) {
564585 server . post ( '' )
You can’t perform that action at this time.
0 commit comments