diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 92c27c9a8a..d42c97a518 100755 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -36,7 +36,8 @@ function setHeader(list, name, value) { function llistToHeaders(list, count) { var ret = {}; while (!linkedList.isEmpty(list)) { - var item = linkedList.shift(list); + var item = list._idlePrev; + linkedList.remove(item); var key = item[0]; if (ret[key]) { @@ -279,8 +280,18 @@ class Http2ServerResponse extends Stream { }; this[kStream] = stream; stream[kResponse] = this; - this[kHeaders] = linkedList.create(); - this[kTrailers] = linkedList.create(); + var headerList = { + _idleNext: null, + _idlePrev: null, + }; + linkedList.init(headerList); + this[kHeaders] = headerList; + var trailersList = { + _idleNext: null, + _idlePrev: null, + }; + linkedList.init(trailersList); + this[kHeaders] = trailersList; this.writable = true; stream.on('drain', onStreamResponseDrain); stream.on('error', onStreamResponseError); diff --git a/test/parallel/test-http2-server-set-header.js b/test/parallel/test-http2-server-set-header.js new file mode 100644 index 0000000000..7e97c52bb1 --- /dev/null +++ b/test/parallel/test-http2-server-set-header.js @@ -0,0 +1,39 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const http2 = require('http2'); +const path = require('path'); +const tls = require('tls'); +const net = require('net'); +const fs = require('fs'); +const body = + '