Only setting content-type to JSON if there actually is content

Since no content at all is not valid JSON.