Fix POST ctx.ParseBody(); (Actually fixed it this time)

This commit is contained in:
Michael Nolan
2022-07-27 18:30:52 -05:00
parent 0ff38b0211
commit 8a912e2a86
3 changed files with 53 additions and 8 deletions
+10 -1
View File
@@ -17,6 +17,11 @@ internal class SizedStream : Stream
this.len=len;
}
public override int ReadByte()
{
if(pos >= len) return -1;
return strm.ReadByte();
}
public override bool CanRead => strm.CanRead;
public override bool CanSeek => false;
@@ -35,8 +40,10 @@ internal class SizedStream : Stream
public override int Read(byte[] buffer, int offset, int count)
{
int read=(int)Math.Min(count,len-pos);
if(read == 0) return 0;
read=strm.Read(buffer,offset,read);
pos+=read;
return read;
@@ -219,9 +226,11 @@ internal class SizedStream : Stream
{
if(long.TryParse(len_Str,out len))
{
//DajuricSimpleHttpExtensions.Print($"Content-Length: {len}");
return new SizedStream(NetworkStream,len);
}
}
//DajuricSimpleHttpExtensions.Print("Returns NetworkStream");
return NetworkStream;
}
}