@@ -556,6 +556,8 @@ procedure TIdIOHandlerWebsocket.WriteBufferFlush(AByteCount: Integer);
556
556
557
557
function TIdIOHandlerWebsocket.WriteDataToTarget (const ABuffer: TIdBytes;
558
558
const AOffset, ALength: Integer): Integer;
559
+ var
560
+ data: TIdBytes;
559
561
begin
560
562
if UseSingleWriteThread and IsWebsocket and (GetCurrentThreadId <> TIdWebsocketWriteThread.Instance.ThreadID) then
561
563
Assert(False, ' Write done in different thread than TIdWebsocketWriteThread!' );
@@ -574,17 +576,19 @@ function TIdIOHandlerWebsocket.WriteDataToTarget(const ABuffer: TIdBytes;
574
576
end
575
577
else
576
578
begin
579
+ data := ToBytes(ABuffer, ALength, AOffset);
577
580
{ $IFDEF DEBUG_WS}
578
581
if Debughook > 0 then
579
582
OutputDebugString(PChar(Format(' Send (ws, TID:%d, P:%d): %s' ,
580
- [getcurrentthreadid, Self.Binding.PeerPort, BytesToStringRaw(ABuffer)])));
583
+ [getcurrentthreadid, Self.Binding.PeerPort, BytesToStringRaw(data)])));
584
+
581
585
{ $ENDIF}
582
586
try
583
587
if FWriteTextToTarget then
584
- Result := WriteData(ABuffer , wdcText, True{ send all at once} ,
588
+ Result := WriteData(data , wdcText, True{ send all at once} ,
585
589
webBit1 in ClientExtensionBits, webBit2 in ClientExtensionBits, webBit3 in ClientExtensionBits)
586
590
else
587
- Result := WriteData(ABuffer , wdcBinary, True{ send all at once} ,
591
+ Result := WriteData(data , wdcBinary, True{ send all at once} ,
588
592
webBit1 in ClientExtensionBits, webBit2 in ClientExtensionBits, webBit3 in ClientExtensionBits);
589
593
except
590
594
FClosedGracefully := True;
0 commit comments