CastAndValidate: Fix incorrect content-type handling
If there was no content type header in the request, it was
transformed to "", making it fall through a check that
no body was present if the body is optional , resulting
in "Invalid value for header: content-type" errors.