Title: HTTP parser premature close · Issue #29609 · nodejs/node · GitHub
Open Graph Title: HTTP parser premature close · Issue #29609 · nodejs/node
X Title: HTTP parser premature close · Issue #29609 · nodejs/node
Description: Version: v12.10.0 Platform: macOS Subsystem: http, stream I'm running across an issue where when no response data is written during the "request" event call, the HTTP handling either closes the response without sending any apparent reply...
Open Graph Description: Version: v12.10.0 Platform: macOS Subsystem: http, stream I'm running across an issue where when no response data is written during the "request" event call, the HTTP handling either closes the res...
X Description: Version: v12.10.0 Platform: macOS Subsystem: http, stream I'm running across an issue where when no response data is written during the "request" event call, the HTTP handling either ...
Opengraph URL: https://github.com/nodejs/node/issues/29609
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"HTTP parser premature close","articleBody":"\u003c!--\r\nThank you for reporting a possible bug in Node.js.\r\n\r\nPlease fill in as much of the template below as you can.\r\n\r\nVersion: output of `node -v`\r\nPlatform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)\r\nSubsystem: if known, please specify the affected core module name\r\n\r\nIf possible, please provide code that demonstrates the problem, keeping it as\r\nsimple and free of external dependencies as you can.\r\n--\u003e\r\n\r\n* **Version**: v12.10.0\r\n* **Platform**: macOS\r\n* **Subsystem**: http, stream\r\n\r\n\u003c!-- Please provide more details below this comment. --\u003e\r\n\r\n\r\nI'm running across an issue where when no response data is written during the \"request\" event call, the HTTP handling either closes the response without sending any apparent reply, or sends a `Connection: close` response but doesn't end the stream.\r\n\r\nThis is a strange behavior that I can't find an explanation for and I can't come up with any workaround; so I think this is a bug.\r\n\r\n**Case 1**\r\n\r\n```javascript\r\n\"use strict\";\r\nconst http = require('http');\r\nconst makeDuplexPair = require('./test/common/duplexpair.js');\r\n\r\nconst message = 'GET / HTTP/1.1\\r\\nHost: example.com\\r\\nConnection: close\\r\\n\\r\\n';\r\nconst server = http.createServer(function(req, res){\r\n\tconsole.log('Have request: ', req.method, req.url);\r\n\treq.resume();\r\n\treq.once('end', function(){\r\n\t\tconsole.log('(request end)');\r\n\t\tres.end('Fin\\r\\n');\r\n\t});\r\n});\r\n\r\nconst {clientSide, serverSide} = makeDuplexPair();\r\nclientSide.end(message);\r\nclientSide.pipe(process.stdout);\r\nclientSide.once('end', function(){ console.log('(Connection closed)'); });\r\n\r\nserver.emit('connection', serverSide);\r\n```\r\n\r\nActual:\r\n```\r\nHave request: GET /\r\n(request end)\r\n(Connection closed)\r\n```\r\n\r\nI expect to see the HTTP response output, but the connection simply closes.\r\n\r\n\r\n**Case 2** (using clientSide.write instead of clientSide.end)\r\n```javascript\r\n\"use strict\";\r\nconst http = require('http');\r\nconst makeDuplexPair = require('./test/common/duplexpair.js');\r\n\r\nconst message = 'GET / HTTP/1.1\\r\\nHost: example.com\\r\\nConnection: close\\r\\n\\r\\n';\r\nconst server = http.createServer(function(req, res){\r\n\tconsole.log('Have request: ', req.method, req.url);\r\n\treq.resume();\r\n\treq.once('end', function(){\r\n\t\tconsole.log('(request end)');\r\n\t\tres.end('Fin\\r\\n');\r\n\t});\r\n});\r\n\r\nconst {clientSide, serverSide} = makeDuplexPair();\r\nclientSide.write(message);\r\nclientSide.pipe(process.stdout);\r\nclientSide.once('end', function(){ console.log('(Connection closed)'); });\r\n\r\nserver.emit('connection', serverSide);\r\n```\r\n\r\nI expect to see `(Connection closed)` at the end, but I do not.\r\n\r\nActual:\r\n```\r\nHave request: GET /\r\n(request end)\r\nHTTP/1.1 200 OK\r\nDate: Thu, 19 Sep 2019 01:01:49 GMT\r\nConnection: close\r\nContent-Length: 5\r\n\r\nFin\r\n```\r\n\r\n\r\nIn one or the other case I expect:\r\n```\r\nHave request: GET /\r\n(request end)\r\nHTTP/1.1 200 OK\r\nDate: Thu, 19 Sep 2019 01:01:49 GMT\r\nConnection: close\r\nContent-Length: 5\r\n\r\nFin\r\n(Connection closed)\r\n```\r\n\r\nAs far as I can tell, there's no way to do this.","author":{"url":"https://github.com/awwright","@type":"Person","name":"awwright"},"datePublished":"2019-09-19T01:04:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/29609/node/issues/29609"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ce459695-d458-f111-e40f-a4b912928bf9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC98:FE029:374790E:4F24EB0:6A4FD5A2 |
| html-safe-nonce | cfee4fd1df0759a1d4cafff9f4ebd680c9bbb974e58832ad2017ade32b1c700d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzk4OkZFMDI5OjM3NDc5MEU6NEYyNEVCMDo2QTRGRDVBMiIsInZpc2l0b3JfaWQiOiI2ODk0NjAwODQwNDM2MjQxODI2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f2d3cd761fe1285c82092f342482ec82b06216dfe83e9a567698ee0aef408ab3 |
| hovercard-subject-tag | issue:495521369 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/29609/issue_layout |
| twitter:image | https://opengraph.githubassets.com/038310f7f727bd09905a288cf69068c8e0f5775e52239cc434d3f7690190f640/nodejs/node/issues/29609 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/038310f7f727bd09905a288cf69068c8e0f5775e52239cc434d3f7690190f640/nodejs/node/issues/29609 |
| og:image:alt | Version: v12.10.0 Platform: macOS Subsystem: http, stream I'm running across an issue where when no response data is written during the "request" event call, the HTTP handling either closes the res... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | awwright |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19b98c3d9767bb8a56238a89ff8401d1cbdf3bc5c353799aacf49fe6c76b4b7c |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 142593e66413bbae27fd485859993597d5a3b104 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width