Skip to content

Expose (likely?) Content-Type on response object #4051

Description

@btmorex

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 12.15.0
  • module version: 19.1.1
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...):
  • any other relevant information:

What problem are you trying to solve?

I'd like to set some standard headers in an onPreResponse handler, but only for responses where Content-Type is set to text/html. It seems that Hapi already knows the likely Content-Type (assuming later code doesn't change it) via the private _contentType property. I'm using it, but it would be nice if it were part of the public API.

Do you have a new or modified API suggestion to solve the problem?

Either expose the Content-Type publicly on the Response object or add it to response.headers. I should mention that my expectation prior to reading the docs was that response.headers['content-type'] would already be set.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions