private Byte[] ReadChunk(PduStreamReader reader) { var chunkSizeLine = reader.ReadLine()?.Trim(); if (chunkSizeLine == null) { return(null); } var chunkSize = Convert.ToInt32(chunkSizeLine, 16); if (chunkSize == 0) { return(null); } var chunkBuffer = new Byte[chunkSize]; var readTotal = 0; do { var read = reader.Read(chunkBuffer, readTotal, chunkSize - readTotal); if (read == 0) { return(null); } readTotal += read; } while(readTotal < chunkSize); if (reader.ReadLine() == null) { return(null); } return(chunkBuffer); }
private void ParseTransferHttp1(PduStreamReader reader) { var payloadBuffer = new List <Byte>(); var buffer = new Byte[4096]; while ((reader.Read(buffer, 0, buffer.Length)) > 0) { payloadBuffer.AddRange(buffer); } this.Payload = payloadBuffer.ToArray(); }
private void ParseTransferIdentity(PduStreamReader reader, Int32 contentLength) { this.Payload = new Byte[contentLength]; if (contentLength == 0) { return; } var readTotal = 0; Int32 read; do { read = reader.Read(this.Payload, readTotal, contentLength - readTotal); readTotal += read; } while (readTotal < contentLength && read != 0); if (contentLength != readTotal) { this.PayloadIncomplete = true; } }