private static String requestBodyAsStr(Request request) {
        RequestBody requestBody = request.body();
        if (requestBody == null) {
            return null;
        }
        MediaType contentType = requestBody.contentType();
        if (contentType != null && !TextUtils.isEmpty(contentType.toString())) {
            if (contentType.toString().contains("form-data")
                    || contentType.toString().contains("octet-stream")) {
                try {
                    return " (binary " + requestBody.contentLength() + "-byte body omitted)";
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
        }
        String contentEncoding = request.header("Content-Encoding");
        boolean gzip = "gzip".equalsIgnoreCase(contentEncoding);
        Buffer buffer = new Buffer();
        try {
            requestBody.writeTo(buffer);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
        if (!isPlaintext(buffer)) {
            try {
                return " (binary " + requestBody.contentLength() + "-byte body omitted)";
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
        try {
            if (requestBody.contentLength() > MAX_SIZE_BODY) {
                return "(binary " + requestBody.contentLength() + "-byte body omitted)";
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sourceToStrInternal(buffer, gzip, requestBody.contentType());
    }
Returns true if the body in question probably contains human readable text. Uses a small sample
of code points to detect unicode control characters commonly used in binary file signatures.
pandora-core/src/main/java/tech/linjiang/pandora/network/OkHttpInterceptor.java