Repository navigation
Feature request: passing headers to response.writeContinue() #7588
Description
Activity
Interesting... I wouldn't be opposed to this.
/cc @nodejs/http
- addedhttpIssues and PRs related to the http subsystem.Issues and PRs related to the http subsystem.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Jul 7, 2016 Seem like an ok idea to me.
Maybe I can add some things I've noticed so far.
My first thought was to extend the response.writeContinue() to be similar to response.writeHead()
But for setting those push headers, you'd need to set the same header multiple times.
The current API for normal HTTP-responses doesn't allow multiple headers with response.setHeader and response.writeHead. They are 'merged'.
So should the writeHead/setHeader API be extended first to allow for multiple headers ?
An other thing I noticed is that I can already do this as a hack by calling some lower level methods:
var CRLF = '\r\n'; var links = ['/style1.css', '/style2.css']; var strlinks = ''; for (var i in links) { strlinks += CRLF + 'Link: <'+links[i]+'>; rel=preload' } response._writeRaw ('HTTP/1.1 100 Continue' + strlinks + CRLF + CRLF, 'ascii');
The current API for normal HTTP-responses doesn't allow multiple headers with response.setHeader and response.writeHead.
This is a very common misconception, especially since the HTTP client in Node.js (which many people to use to confirm) also does a merge on read. You can very easily emit the same header multiple times in the current API: you just set the header's value to an array instead of a string, and each element in the array will be a separate header line in the response.
So should the writeHead/setHeader API be extended first to allow for multiple headers ?
If we make it match
.writeHead, then it would, as.writeHeadalready does.This morning I had the same idea before I read your comment. I remembered you can combine multiple of the same HTTP headers in a single response separated with ','. Just tested that with h2o and it works just fine. So all we need to do is extend writeContinue () to be more like writeHead()
Pull request welcome.
This issue has been inactive for sufficiently long that it seems like perhaps it should be closed. Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree. I'm just tidying up and not acting on a super-strong opinion or anything like that.
It would be very useful if someone (I'm willing to create a pull request for it) would add the ability to set the headers of the Continue intermediate headers. One reason for it, is to tell the reverse proxy/webserver which URLs do to a HTTP/2 push for:
http://blog.kazuhooku.com/2016/06/h2o-http2-server-201-210-beta1-released.html