GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HTTP Parser issues with newline `\n` · Issue #34576 · nodejs/node

HTTP Parser issues with newline \n #34576

New issue
Copy link
New issue
Copy link
Closed
Closed
HTTP Parser issues with newline \n#34576
Copy link
Labels
httpIssues and PRs related to the http subsystem.

Description

@ronag
ronag
opened on Jul 31, 2020
Issue body actions

The following issue was found while working against a CouchDB changes stream which uses a newline \n as a form of a heartbeat on a long polling connection.

OS: MacOS, Node 14.6

Will invoke kOnTimeout after kOnHeadersComplete. Also will stop invoking kOnExecute but will keep invoking kOnBody.

Refs: https://github.com/mcollina/undici/issues/268
Refs: https://github.com/mcollina/undici/issues/269

const net = require('net')
const { HTTPParser } = process.binding('http_parser') // eslint-disable-line

net.createServer(socket => {
  socket.write('HTTP/1.1 200 OK\r\n')
  socket.write('Transfer-Encoding: chunked\r\n\r\n')
  setInterval(() => {
    socket.write('1\r\n')
    socket.write('\n\r\n')
  }, 500)
}).listen(3111)

const socket = net.connect(3111, '127.0.0.1')
const parser = new HTTPParser(HTTPParser.RESPONSE, false)
parser.initialize(
  HTTPParser.RESPONSE,
  {},
  0,
  false,
  1e3
)

parser[HTTPParser.kOnTimeout] = () => {
  console.log('kOnTimeout')
}

parser[HTTPParser.kOnHeaders] = (rawHeaders) => {
  console.log('kOnHeaders')
}

parser[HTTPParser.kOnExecute] = (ret) => {
  console.log('kOnExecute')
}

parser[HTTPParser.kOnHeadersComplete] = (versionMajor, versionMinor, rawHeaders, method,
  url, statusCode, statusMessage, upgrade, shouldKeepAlive) => {
  console.log('kOnHeadersComplete')
}

parser[HTTPParser.kOnBody] = (chunk, offset, length) => {
  console.log('kOnBody')
}

parser[HTTPParser.kOnMessageComplete] = () => {
  console.log('kOnMessageComplete')
}

parser.consume(socket._handle)

Activity

  1. ronag
    added
    httpIssues and PRs related to the http subsystem.
    on Jul 31, 2020
  2. ronag commented on Jul 31, 2020

    @ronag
    ronag
    on Jul 31, 2020
    MemberAuthor
    More actions

    @nodejs/http @addaleax @indutny

  3. ronag
    changed the title [-]HTTP Parser Issues[/-] [+]HTTP Parser Issues with newline `\n`[/+] on Jul 31, 2020
  4. ronag
    changed the title [-]HTTP Parser Issues with newline `\n`[/-] [+]HTTP Parser issues with newline `\n`[/+] on Jul 31, 2020
  5. ronag commented on Jul 31, 2020

    @ronag
    ronag
    on Jul 31, 2020
    MemberAuthor
    More actions

    I think kOnExecute doesn't get executed because it keeps thinking that there is a headers timeout.

  6. ronag
    closed this as completedin da4d8deon Aug 2, 2020
  7. codebytere
    added a commit that references this issue on Aug 5, 2020

    http: reset headers timeout on headers complete

    7322e58
  8. MayaLekova
    added a commit that references this issue on May 22, 2026

    http: reset headers timeout on headers complete

    da4d8de
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

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.