in grpc-web/callout/src/main/java/com/google/apigee/callouts/ProtobufDecoder.java [165:180]
String decodeAsJSON(InputStream inputStream, Boolean protoIsBase64, Descriptors.Descriptor descriptor, PrintStream stdout, PrintStream stderr) throws IOException, Descriptors.DescriptorValidationException {
byte[] messageBytes = inputStream.readAllBytes();
if (messageBytes.length == 0) {
return "{}";
}
if (protoIsBase64 != null && protoIsBase64) {
messageBytes = Base64.getDecoder().decode(messageBytes);
}
byte[] msgPayload = Arrays.copyOfRange(messageBytes, PAYLOAD_OFFSET, messageBytes.length);
//stdout.println("message-length: " + msgPayload.length);
DynamicMessage msg = DynamicMessage.parseFrom(descriptor, msgPayload);
return JsonFormat.printer().print(msg);
}