Skip to content

Commit

Permalink
http2: fix pseudo-headers order
Browse files Browse the repository at this point in the history
Keep pseudo-headers order same as sent order

Fixes: nodejs#38797
  • Loading branch information
ofir committed Jan 30, 2022
1 parent 64c4b55 commit b3894f9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/internal/http2/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ const kNeverIndexFlag = StringFromCharCode(NGHTTP2_NV_FLAG_NO_INDEX);
const kNoHeaderFlags = StringFromCharCode(NGHTTP2_NV_FLAG_NONE);
function mapToHeaders(map,
assertValuePseudoHeader = assertValidPseudoHeader) {
let ret = '';
let headers = '';
let pseudoHeaders = '';
let count = 0;
const keys = ObjectKeys(map);
const singles = new SafeSet();
Expand Down Expand Up @@ -520,7 +521,7 @@ function mapToHeaders(map,
err = assertValuePseudoHeader(key);
if (err !== undefined)
throw err;
ret = `${key}\0${value}\0${flags}${ret}`;
pseudoHeaders += `${key}\0${value}\0${flags}`;
count++;
continue;
}
Expand All @@ -533,16 +534,16 @@ function mapToHeaders(map,
if (isArray) {
for (j = 0; j < value.length; ++j) {
const val = String(value[j]);
ret += `${key}\0${val}\0${flags}`;
headers += `${key}\0${val}\0${flags}`;
}
count += value.length;
continue;
}
ret += `${key}\0${value}\0${flags}`;
headers += `${key}\0${value}\0${flags}`;
count++;
}

return [ret, count];
return [pseudoHeaders + headers, count];
}

class NghttpError extends Error {
Expand Down

0 comments on commit b3894f9

Please sign in to comment.