Skip to content

Proposal: http: automaticly send Content-Length header when possible #1044

Description

@tellnes

I propose we make http set the Content-Length header when the user does only call OutgoingMessage.prototype.end and not write or writeHead.

Eg.

require('http').createServer(function (req, res) {
  res.end('Hello World')
}).listen(1337)
HTTP/1.1 200 OK
Date: Tue, 03 Mar 2015 19:42:18 GMT
Connection: keep-alive
Content-Length: 11

Hello World

It is a trivial change in lib/, but breaks a lot of tests.

Activity

  1. tellnes commented on Mar 3, 2015

    @tellnes
    ContributorAuthor

    It breaks 20 tests, but mostly it looks like trivial stuff like:

    AssertionError: { date: 'coffee o clock', 'content-length': '10' } deepEqual { date: 'coffee o clock' }
    
  2. Fishrock123 commented on Mar 3, 2015

    @Fishrock123
    Contributor

    Sending content-length here seams like it should be expected, given .write()'s automatic headers behaviour.

  3. bnoordhuis commented on Mar 3, 2015

    @bnoordhuis
    Member

    Seems reasonable to me. It would save a few bytes per response as well.

  4. tellnes commented on Mar 3, 2015

    @tellnes
    ContributorAuthor

    Ok, I'll see if I can get something ready later tonight or tomorrow.

  5. added
    httpIssues and PRs related to the http subsystem.
    on Mar 4, 2015
  6. added a commit that references this issue on Mar 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues and PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions