Docker daemon authorization plugins reject POST or PUT requests that have a
content type `application/json` header but no content length header. This
commit ensures that a content length header is provided in these cases.
This is a cherry-pick of the changes in d5b2836ec90c5a94b2201c074db5e3fcc99a9204
which were lost in a forward-merge.
Fixes gh-23957