Hi,
In loop where you are reading data:
while(ms.Position < req.ContentLength)
{
bytesRead = worker.ReadEntityBody(buffer, buffer.Length);
ms.Write(buffer, 0, bytesRead);
}
realloate buffer for last reading. I've discovered that if you have
last e.g. 58 B for read in request, and you are reading to buffer
allocated to 100 B with code:
bytesRead = worker.ReadEntityBody(buffer, buffer.Length);
then (IMHO!!!!) system will wait for buffer.Length Bytes. So I
reallocate the buffer to the last of request data and everything goes
well - except of two days of lost time and de-ja vu, because I've
already solved this problem, but forget the solution very quickly...
Solution is in code below.
while(ms.Position < req.ContentLength)
{
bytesRead = worker.ReadEntityBody(buffer, buffer.Length);
ms.Write(buffer, 0, bytesRead);
newBufferSize = req.ContentLength - (int)ms.Position;
if(newBufferSize < BUFFER_SIZE && newBufferSize > 0)
buffer = new byte[req.ContentLength - ms.Position];
}
With best regard,
Ozon.