Skip to content

Content-type header is null when empty response is returned #4133

@vikmovcan

Description

@vikmovcan

Support plan

  • is this issue currently blocking your project? (no):
  • is this issue affecting a production system? (yes):

Context

  • node version: 12.16.3
  • module version with issue: 19.2.0
  • last module version without issue: 19.1.1
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi application
  • any other relevant information:
    After updating to v19.2.0 from v19.1.1 it was noticed that the headers of responses with no content now contain the content-type header with the value of null.
    Before v19.2.0, the content-type header was omitted for such responses.

What are you trying to achieve or the steps to reproduce?

The issue can be reproduced by returning an empty response from a route handler.
I suspect this may be due to changes here: ed0688c

  server.route({
      method: "GET",
      path: "/test",
      handler: (request, h) => {
         // response headers contain content-type as null on v19.2.0
         // response headers omit content-type  header on v19.1.1 and lower
        return h.response().code(204);
      },
  });

What was the result you got?

response headers containing content-type of null

What result did you expect?

response headers not containing content-type header

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportQuestions, discussions, and general support

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions