Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 3c5d283

Browse files
Tragetaschenmoozzyk
authored andcommitted
Fix the VarInt example for the 2GiB
`0x7fffffff` has 31 binary ones. The first four bytes of the VarInt account for 4*7=28, so the fifth byte only needs the remaining three
1 parent 72514f3 commit 3c5d283

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

specs/HubProtocol.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ Examples:
612612
* VarInt: `0x35` (`%00110101`) - the most significant bit is 0 so the value is %x0110101 i.e. 0x35 (53)
613613
* VarInt: `0x80 0x25` (`%10000000 %00101001`) - the most significant bit of the first byte is 1 so the remaining bits (%x0000000) are the lowest bits of the value. The most significant bit of the second byte is 0 meaning this is last byte of the VarInt. The actual value bits (%x0101001) need to be prepended to the bits we already read so the values is %01010010000000 i.e. 0x1480 (5248)
614614

615-
The biggest supported payloads are 2GB in size so the biggest number we need to support is 0x7fffffff which when encoded as VarInt is 0xFF 0xFF 0xFF 0xFF 0x7F - hence the maximum size of the length prefix is 5 bytes.
615+
The biggest supported payloads are 2GB in size so the biggest number we need to support is 0x7fffffff which when encoded as VarInt is 0xFF 0xFF 0xFF 0xFF 0x07 - hence the maximum size of the length prefix is 5 bytes.
616616

617617
For example, when sending the following frames (`\n` indicates the actual Line Feed character, not an escape sequence):
618618

src/Microsoft.AspNetCore.SignalR.Common/Internal/Formatters/BinaryMessageParser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static bool TryParseMessage(ref ReadOnlyBuffer<byte> buffer, out ReadOnly
2929
// byte is 0 meaning this is last byte of the VarInt. The actual value bits (%x0101001) need to be
3030
// prepended to the bits we already read so the values is %01010010000000 i.e. 0x1480 (5248)
3131
// We support paylads up to 2GB so the biggest number we support is 7fffffff which when encoded as
32-
// VarInt is 0xFF 0xFF 0xFF 0xFF 0x7F - hence the maximum length prefix is 5 bytes.
32+
// VarInt is 0xFF 0xFF 0xFF 0xFF 0x07 - hence the maximum length prefix is 5 bytes.
3333

3434
var length = 0U;
3535
var numBytes = 0;

0 commit comments

Comments
 (0)