Skip to content

Commit 173caa6

Browse files
committed
0-padding binary representations in annotations on letters in written HPACK strings
1 parent 61b3966 commit 173caa6

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3740,7 +3740,7 @@ var HPACKBytes = class extends Bytes {
37403740
for (let i = 0; i < inBytesLength; i++) {
37413741
const ch = inBytes[i];
37423742
let [encodedValue, remainingBitCount] = HuffmanCodes[ch];
3743-
if (1) bitComment += ` ${encodedValue.toString(2)}=` + (ch >= 33 && ch <= 126 ? String.fromCharCode(ch) : `0x${ch.toString(16).padStart(2, " ")}`);
3743+
if (1) bitComment += ` ${encodedValue.toString(2).padStart(remainingBitCount, "0")}=` + (ch >= 33 && ch <= 126 ? String.fromCharCode(ch) : `0x${ch.toString(16).padStart(2, " ")}`);
37443744
while (remainingBitCount > 0) {
37453745
if (outBitIndex === 8) {
37463746
outBytes[outByteIndex++] = outByte;

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,8 +3284,8 @@ var HPACKBytes = class extends Bytes {
32843284
for (let i = 0; i < inBytesLength; i++) {
32853285
const ch = inBytes[i];
32863286
let [encodedValue, remainingBitCount] = HuffmanCodes[ch];
3287-
if (0) bitComment += ` ${encodedValue.toString(2)}=` + (ch >= 33 && ch <= 126 ? String.fromCharCode(ch) :
3288-
`0x${ch.toString(16).padStart(2, " ")}`);
3287+
if (0) bitComment += ` ${encodedValue.toString(2).padStart(remainingBitCount, "0")}=` + (ch >= 33 && ch <=
3288+
126 ? String.fromCharCode(ch) : `0x${ch.toString(16).padStart(2, " ")}`);
32893289
while (remainingBitCount > 0) {
32903290
if (outBitIndex === 8) {
32913291
outBytes[outByteIndex++] = outByte;

src/util/hpackBytes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export class HPACKBytes extends Bytes {
331331
for (let i = 0; i < inBytesLength; i++) {
332332
const ch = inBytes[i];
333333
let [encodedValue, remainingBitCount] = HuffmanCodes[ch];
334-
if (chatty) bitComment += ` ${encodedValue.toString(2)}=` + (ch >= 33 && ch <= 126 ? String.fromCharCode(ch) : `0x${ch.toString(16).padStart(2, ' ')}`);
334+
if (chatty) bitComment += ` ${encodedValue.toString(2).padStart(remainingBitCount, '0')}=` + (ch >= 33 && ch <= 126 ? String.fromCharCode(ch) : `0x${ch.toString(16).padStart(2, ' ')}`);
335335
while (remainingBitCount > 0) {
336336
if (outBitIndex === 8) {
337337
outBytes[outByteIndex++] = outByte;

0 commit comments

Comments
 (0)