Closed mturczyn closed 1 week ago
Another in chapter 6: there is code snipper with line
Delay = TimeSpan.FromMilliseconds(200), // Wait between each try
and below description states:
with a two-second pause
which is not true, as 200 ms was specified
Another inconsistency in chapter 8: in GZip example, we have piece of code:
public byte[] CompressData(byte[] data)
{
using var outputStream = new MemoryStream();
using (var gzipStream = new GZipStream(outputStream, CompressionMode.Compress))
{
gzipStream.Write(data, 0, data.Length);
}
return outputStream.ToArray();
}
In Brotli example however, we have:
public static byte[] CompressData(byte[] data)
{
using var outputStream = new MemoryStream();
using var brotliStream = new BrotliStream(outputStream, CompressionMode.Compress);
brotliStream.Write(data, 0, data.Length);
return outputStream.ToArray();
}
The difference is how using
is used with gzipStream
and brotliStream
- one using is scoped, while the other one is without braces { }
. If it's irelevant, i would keep it consistent, but it maybe that the compression stream has to be closed before, that's why first example maybe correct, while Brotli example may not work.
In chapter 5, there's code example
followed by explanation:
This is wrong:
await HandleClientAsync(client);
waits to handle the client (awaits) and does not proceed to listening again. It will accept new client when it's done with current. Not what is suggested in text. To correct that, it should bevar task = HandleClientAsync(client);
and then tasks should be awaited later on as needed.