TIndySparkleHTTPServer Exception 2

Hi,

The previous post was atomatically closed with out a solution.

I´'m using the following code to decompress deflate cliente request, If I use HttpSys Server it works ok, using TIndySparkleHTTPServer I get ACCESS_VIOLATION exception on "TStream.SetPosition".

Any hint what am I doing wrong?

Thanks in advance,

Omar Zelaya

if Context.Request.Headers.Get('content-encoding') = 'deflate' then
begin
TempStream := TMemoryStream.Create;
try
repeat
BytesRead := Context.Request.ContentStream.Read(Buffer[0], BufSize);
TempStream.Write(Buffer[0], BytesRead);
until BytesRead <> BufSize;
TempStream.Position := 0;
Context.Request.ContentStream.Free;
Context.Request.ContentStream := TZDecompressionStream.Create(TempStream, 15, True);
Context.Request.Headers.SetValue('content-length', '-1');
except
TempStream.Free;
raise;
end;
end

Can you please provide the call stack of the error?

image

Right, I see it. You cannot destroy ContentStream, because Indy is using it.
In this case you should just not destroy ContentStream, Indy will do it.