buffstreams icon indicating copy to clipboard operation
buffstreams copied to clipboard

Incorrect header length

Open luna-duclos opened this issue 9 years ago • 1 comments

Headers are encoded with Varint encoding, as per the spec for varint: https://developers.google.com/protocol-buffers/docs/encoding

Varint encoding uses the 8th bit of each byte as a more flag. As such, only 7 bits per byte actually contain data.

This means that a 64 bit number now needs 80 bits to actually be encoded if the number is large enough.

luna-duclos avatar Oct 11 '16 13:10 luna-duclos

Thanks for finding this. Although I could account for this by adjusting the calculation for the header size, I'm wondering if you know of a better approach for calculating this size not using Varint encoding?

I have gone through a few different approaches here and Varint seemed the most reliable, but I know there are some other approaches, wondering if you have any opinions on a better one?

StabbyCutyou avatar Oct 11 '16 13:10 StabbyCutyou