encodeBody method
Encodes the request payload into bytes.
For HTTP requests, the returned bytes are used as the request body. For socket-based protocols (e.g. WebSocket), the returned bytes represent the message payload to be sent through the connection.
By default, this method returns bodyBytes if available; otherwise it encodes bodyString as UTF-8 bytes.
Implementation
List<int>? encodeBody({ServiceProtocol protocol = ServiceProtocol.http}) {
final bytes = bodyBytes;
if (bytes != null) return bytes;
final str = bodyString;
if (str != null) return StringUtils.toBytes(str);
return null;
}