TsgcWebSocketFirewallMethods › IsFrameSizeAllowed

IsFrameSizeAllowed Method

Checks a single WebSocket frame size against WebSocketProtection.MaxFrameSize and returns whether it is within the configured limit.

Syntax

function IsFrameSizeAllowed(aSize: Integer): Boolean;

Parameters

NameTypeDescription
aSizeIntegerSize in bytes of the frame or message payload to validate.

Return Value

True if the frame size is within limits (or WebSocketProtection is disabled, or MaxFrameSize is 0 meaning "unlimited"); False when the frame exceeds the maximum. (Boolean)

Remarks

This is one of three granular WebSocket handshake/frame helpers (IsOriginAllowed, IsFrameSizeAllowed, IsSubprotocolAllowed) that are normally invoked automatically by IsMessageAllowed and the server integration. Use IsFrameSizeAllowed directly when writing custom frame inspectors or validating buffered data before forwarding it to another subsystem.

Example

if not sgcWebSocketFirewall1.IsFrameSizeAllowed(Length(aBytes)) then
  raise Exception.Create('frame exceeds configured MaxFrameSize');

Back to Methods