Title: Make http.OutgoingMessage._writeRaw public · Issue #22624 · nodejs/node · GitHub
Open Graph Title: Make http.OutgoingMessage._writeRaw public · Issue #22624 · nodejs/node
X Title: Make http.OutgoingMessage._writeRaw public · Issue #22624 · nodejs/node
Description: Is your feature request related to a problem? Please describe. I am trying to return HTTP informational statuses to the client. In particular 100, 102, 103 but I would also like to open the door to being able to support future informatio...
Open Graph Description: Is your feature request related to a problem? Please describe. I am trying to return HTTP informational statuses to the client. In particular 100, 102, 103 but I would also like to open the door to...
X Description: Is your feature request related to a problem? Please describe. I am trying to return HTTP informational statuses to the client. In particular 100, 102, 103 but I would also like to open the door to...
Opengraph URL: https://github.com/nodejs/node/issues/22624
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make http.OutgoingMessage._writeRaw public","articleBody":"\u003c!--\r\nThank you for suggesting an idea to make Node.js better.\r\n\r\nPlease fill in as much of the template below as you're able.\r\n--\u003e\r\n\r\n**Is your feature request related to a problem? Please describe.**\r\n\r\nI am trying to return HTTP informational statuses to the client. In particular 100, 102, 103 but I would also like to open the door to being able to support future informational status codes.\r\n\r\nBoth 100 and 102 have a dedicated method:\r\n\r\n* `HttpServerResponse.sendContinue` for 100 and\r\n* `HttpServerResponse.sendProcessing` for 102.\r\n\r\nIt would be possible to add another function like it (sendEarlyHints), but it seems a little silly given that these informational statuses more or less follow the same structure. \r\n\r\nThe http2 library solves this with the `additionalHeaders` function. To illustrate, this is how I send *any* informational status using http2:\r\n\r\n```javascript\r\nconst otherHeaders = { };\r\nconst status = 103;\r\n\r\nstream.additionalHeaders({\r\n ':status': status,\r\n ...otherHeaders\r\n});\r\n```\r\n\r\nThis is how I do it for the HTTP1 api:\r\n\r\n```javascript\r\nconst otherHeaders = { };\r\nconst status = 103;\r\nconst rawHeaders = [];\r\n for (const headerName of Object.keys(outHeaders)) {\r\n const headerValue = outHeaders[headerName];\r\n if (Array.isArray(headerValue)) {\r\n for (const headerVal of headerValue) {\r\n rawHeaders.push(`${headerName}: ${headerVal}\\r\\n`);\r\n }\r\n } else {\r\n rawHeaders.push(`${headerName}: ${headerValue}\\r\\n`);\r\n }\r\n}\r\n\r\nconst writeRaw = promisify(res._writeRaw.bind(this.inner));\r\nconst message = `HTTP/1.1 ${status} ${http.STATUS_CODES[status]}\\r\\n${rawHeaders.join('')}\\r\\n`;\r\nawait writeRaw(message, 'ascii');\r\n```\r\n\r\nThe problem here is that I'm using `res._writeRaw`, an undocumented 'private' feature. I would like to not have to rely on this, but as far as I can tell, it's the only 'sane' way.\r\n\r\n**Describe the solution you'd like**\r\n\r\nMake `_writeRaw` a documented, supported feature OR supply a reasonable API for returning any 1xx status header. \r\n\r\n**Describe alternatives you've considered**\r\n\r\nAs far as I know there's no real alternative.","author":{"url":"https://github.com/evert","@type":"Person","name":"evert"},"datePublished":"2018-08-31T15:05:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/22624/node/issues/22624"}
| 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:0a9241bd-dabf-2bdb-a332-6a073ea2b8c4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9288:3ECFD9:272D21F:375C1D4:6A4CEC1A |
| html-safe-nonce | 784a62964f87c629d5fea9cbe211ac8631329748b7ac06573e72d4a4a2648c3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Mjg4OjNFQ0ZEOToyNzJEMjFGOjM3NUMxRDQ6NkE0Q0VDMUEiLCJ2aXNpdG9yX2lkIjoiMzE0NDc5NzM1OTY3OTc5NDIwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6667e401984238acc9a63605d13bebc0f6db225b69eccf1d56b863459b24986b |
| hovercard-subject-tag | issue:356017770 |
| 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/22624/issue_layout |
| twitter:image | https://opengraph.githubassets.com/21214a2d6d6fa641f500df414ee76e0a5c48e6d03d65968b4f1d00c30e42a54c/nodejs/node/issues/22624 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/21214a2d6d6fa641f500df414ee76e0a5c48e6d03d65968b4f1d00c30e42a54c/nodejs/node/issues/22624 |
| og:image:alt | Is your feature request related to a problem? Please describe. I am trying to return HTTP informational statuses to the client. In particular 100, 102, 103 but I would also like to open the door to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | evert |
| hostname | github.com |
| expected-hostname | github.com |
| None | 299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8 |
| 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 | c5a57f04eeb310f57c73fd6d751d957e2ca27ed2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width