public byte[] getBodyBytes() {
        if (bodyAsBytes != null) {
            return bodyAsBytes;
        } else if (bodyAsText != null) {
            final Charset charset = (contentType != null ? contentType : ContentType.DEFAULT_TEXT).getCharset();
            return bodyAsText.getBytes(charset != null ? charset : StandardCharsets.US_ASCII);
        } else {
            return null;
        }
    }
Gets the body as a byte array.

@return the body as a byte array.
httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleBody.java