EHttpApiException ("Incorrect function") when sending large TStream responses via Http.sys over HTTP/2 + gzip (THttpServerResponseStream.WriteBuffer)

Products / versions:

TMS Sparkle: 3.30.0.3
TMS XData: 5.19.0.3
TMS Aurelius: 5.20.0.3
Server: TSparkleHttpSysDispatcher + TXDataServer + TSparkleCompressMiddleware
Platform: Windows Server 2025 24H2, Http.sys (HTTPS)

Summary

Large JSON (~2mb) service operations returning TStream (via JsonToStream → TActionExecuter.SendStreamResult) fail intermittently when the client uses HTTP/2 and Accept-Encoding: gzip.
Failure occurs in Response.Content.CopyFrom → WriteBuffer on THttpServerResponseStream, with:
EHttpApiException: "HTTP Server API Error. Incorrect function"
Business logic completes; TStringStream read succeeds. The error is raised during response body transfer through compress middleware / Http.sys.

procedure TActionExecuter.SendStreamResult(Stream: TStream);
begin
...
Response.ContentLength := Stream.Size;
Response.Content.CopyFrom(Stream, 0); // fails in WriteBuffer
end;

Custom chunked logging shows:

Total uncompressed size: 2,176,041 bytes
Failure on WriteBuffer at variable offsets (e.g. 1,114,112 or 1,441,792 bytes written)
Source: TStringStream — ReadBuffer succeeds; THttpServerResponseStream stops accepting writes
Response.ContentLength = full uncompressed size before gzip
Exception is handled by OnModuleException.

Environment notes

Accept-Encoding: identity or force HTTP/1.1 → works
Disable HTTP/2 in Http.sys (EnableHttp2Tls=0) → avoids issue

Question:

Is this a known issue in Sparkle 3.30 / XData 5.19 with Http.sys + HTTP/2 + compress middleware + large TStream responses?
Is there a recommended fix or patch?

We are not aware of such issues so far.

Since we are not aware of the issue, no fix or patch yet.

Are you able to consistently reproduce the problem? Do you have a sample client and server projects combination that could reproduce this easily?