Is your feature request related to a problem? Please describe.
http.get allows you to set highwatermark values as of node 13.x. Both IncomingMessage and OutgoingMessage supports setting hwm values in config, those settings are also applied to socket. why can't we do the same for http.createServer
nodejs/node#30135
Describe the solution you'd like
set highwatermark and enable objectMode for response (writable).
Describe alternatives you've considered
Please describe alternative solutions or features you have considered.
set highwatermark and enable objectMode for response
What would that do? It's not at all clear to me what use that has. Please elaborate.
We are trying to generate backpressure over the network. we would like our highwatermark to be 5kb, but this is negated since response's highwatermark is always set to 16kb. we would like to be able to decrease it. so that it can generate back pressure faster.
var server = http.createServer(function (request, response) {
myReadable.pipe(response); //response's highwater marks is set to 16kb by default.
});
Do I understand correctly you want to be able to override writableHighWaterMark like this?
var server = http.createServer(function (request, response) {
response.writableHighWaterMark = 5 * 1024;
myReadable.pipe(response);
});
Yes that's exactly what we would like to do. But I don't think it's possible to overwrite writablehighwatermark after stream is created. So the simplest solution would be to implement at http.createServer level just like http.get
It's read-only right now but that could probably be changed if there's a good enough use case. I've updated the labels.
Having requests inherit it from the http.Server is both clunky and inflexible, IMO.
@bnoordhuis how do we go about this? As far as I can tell both objectMode and highwatermark values for our stream are useless as long as we can't edit those values for response stream.
You can open a pull request with your suggested change. If you're not completely sure yet what direction to take, it's okay to open it in an incomplete state as a draft, to collect feedback.
request
You mentioned response in your original comment. Which one is it?
response. yea that was a typo, and I will try to get a pull request, soon.
There are other way to create back pressure. You can pipe it through a transform stream that applies it.
Most helpful comment
Do I understand correctly you want to be able to override
writableHighWaterMarklike this?