It's possible to enable dynamic mappings for headers though I would only recommend this if the number of headers is reasonably bounded. Configure apm-server.yml with:
setup.template.append_fields:
- name: "http.response.headers"
type: object
enabled: true
dynamic: true
I expect all fields will then be mapped as keyword type, including those like Content-Length and Date.