Error in Encryption middleware demo

Indeed a breaking was introduced. Please use this code for the OnSendingRequest event. We will fix the demo for the next release.

    lClient.HttpClient.OnSendingRequest :=
      procedure(ARequest: THttpRequest)
      var
        pBytes: TBytes;
        Stream: TBytesStream;
      begin
        if lToken <> '' then
          ARequest.Headers.SetValue(cHeaderAuthorization, cTokenPrefix + lToken);
        if ARequest.ContentLength > 0 then
        begin
          if lEncrypted then
          begin
            Stream := TBytesStream.Create;
            try
              Stream.CopyFrom(ARequest.ContentStream);
              pBytes := Copy(Stream.Bytes, 0, Stream.Size);
              pBytes := TAESFunc.Encrypt(pBytes, TAESKeys.GetReceiveKey);
              ARequest.SetContent(pBytes);
            finally
              Stream.Free;
            end;
          end
          else
            ARequest.Headers.AddValue(cCustomXDataHeader, TAESKeys.GetHeaderKey)
        end;
      end;