Code cleanup for network module.

This commit is contained in:
2023-07-11 00:02:14 +08:00
parent c9b348dd4f
commit d89423caf5
4 changed files with 38 additions and 7 deletions

View File

@@ -72,8 +72,8 @@ namespace Cryville.Common.Network.Http11 {
public void ReadChunk() {
if (_chunk != null && _chunk.Length == 0) return;
string[] chunkHeader = Http11Response.ReadLine(_reader).Split(';');
int chunkSize = int.Parse(chunkHeader[0], NumberStyles.HexNumber);
if (chunkSize == -1)
int chunkSize;
if (!int.TryParse(chunkHeader[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out chunkSize))
throw new IOException("Corrupted chunk received");
if (chunkSize == 0) {
_chunk = new byte[0];