Skip to content

Commit

Permalink
Merge pull request #3 from martinschroeder/master
Browse files Browse the repository at this point in the history
Fixed Huffman encoder padding and result string truncation.
  • Loading branch information
bwoebi committed Mar 16, 2018
2 parents f2b2dbf + 42af8dd commit f6f95e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/HPack.php
Expand Up @@ -269,10 +269,10 @@ public static function huffmanEncode(string $input): string {

if ($bitCount & 7) {
// Note: |= can't be used with strings in PHP
$out[$e - 1] = $out[$e - 1] | \chr(0xFF >> ($bitCount & 7));
$out[$byte - 1] = $out[$byte - 1] | \chr(0xFF >> ($bitCount & 7));
}

return \substr($out, 0, $e);
return $i ? \substr($out, 0, $byte) : '';
}

/** @see RFC 7541 Appendix A */
Expand Down

0 comments on commit f6f95e0

Please sign in to comment.