zero-length byte[] is returned. The message is *not* decompressed.
552731
private byte[] readRequestBody() {
        int bytesLeft = m_request.getContentLength();
        if (bytesLeft <= 0) {
            return new byte[0];
        }

        int totalBytesRead = 0;
        try {
            byte[] byteBuffer = new byte[bytesLeft];
            try (InputStream inputStream = m_request.getInputStream()) {
                int bytesRead = -1;
                int offset = 0;
                while ((bytesRead = inputStream.read(byteBuffer, offset, bytesLeft)) > 0) {
                    offset += bytesRead;
                    bytesLeft -= bytesRead;
                    totalBytesRead += bytesRead;
                }
            }
            return byteBuffer;
        } catch (IOException e) {
            String errMsg =
                String.format("Error reading from input request; expected %d bytes; only read %d bytes",
                              m_request.getContentLength(), totalBytesRead);
            throw new RuntimeException(errMsg, e);
        }
    }
1324998
def _unpack(self, data):
        
        msg_magic, msg_length, msg_type = self._unpack_header(data)
        msg_size = self._struct_header_size + msg_length
        # XXX: Message shouldn't be any longer than the data
        payload = data[self._struct_header_size:msg_size]
        return payload.decode('utf-8', 'replace')
1320439
static public byte[] unpack(byte[] packed) {
        if (packed == null) {
            return null;
        }

        int unpackedLen = (packed.length * 8) / 7;
        byte[] unpacked = new byte[unpackedLen];
        int len = unpacked.length;
        int current = 0;
        int bitpos = 0;
        for (int i = 0; i < len; i++) {
            // remove top bit and assign first half of partial bits
            unpacked[i] = (byte)(((packed[current] & 0xFF) >> bitpos) & 0x7F);
            // remove top bit and assign second half of partial bits (if exist)
            if (bitpos >= 2)
                unpacked[i] |= (byte)((packed[++current] << (8 - bitpos)) & 0x7F);
            bitpos = (bitpos + 7) % 8;
            if (bitpos == 0)
                current++;
        }
        // this fixes an ambiguity bug in the specs
        // where the last of 8 packed bytes is 0
        // and it's impossible to distinguish whether it is a
        // trailing '@' character (which is mapped to 0)
        // or extra zero-bit padding for 7 actual data bytes.
        //
        // we opt for the latter, since it's far more likely,
        // at the cost of losing a trailing '@' character
        // in strings whose unpacked size modulo 8 is 0,
        // and whose last character is '@'.
        //
        // an application that wishes to handle this rare case
        // properly must disambiguate this case externally, such
        // as by obtaining the original string length, and
        // appending the trailing '@' if the length
        // shows that there is one character missing.
        if (len % 8 == 0 && len > 0 && unpacked[len-1] == 0) {
            //System.err.println("Hit special case...");
            byte[] fixed = new byte[len-1];
            System.arraycopy(unpacked, 0, fixed, 0, len-1);
            unpacked = fixed;
        }
        return unpacked;
    }
1092525
def decode(in_bytes):
    """"""
    if isinstance(in_bytes, str):
        raise TypeError('Unicode-objects are not supported; byte buffer objects only')
    in_bytes_mv = _get_buffer_view(in_bytes)
    out_bytes = bytearray()
    idx = 0

    if len(in_bytes_mv) > 0:
        while True:
            length = ord(in_bytes_mv[idx])
            if length == 0:
                raise DecodeError("zero byte found in input")
            idx += 1
            end = idx + length - 1
            copy_mv = in_bytes_mv[idx:end]
            if b'\x00' in copy_mv:
                raise DecodeError("zero byte found in input")
            out_bytes += copy_mv
            idx = end
            if idx > len(in_bytes_mv):
                raise DecodeError("not enough input bytes for length code")
            if idx < len(in_bytes_mv):
                if length < 0xFF:
                    out_bytes.append(0)
            else:
                break
    return bytes(out_bytes)
1339441
public static byte[] getBytesUTF8(String string)
    {
        if (string == null)
        {
            return null;
        }

        try
        {
            return string.getBytes("UTF-8");
        }
        catch (UnsupportedEncodingException e)
        {
            // This never happens.
            return null;
        }
    }
765120
function encodedLength(encodedBuffer, index) {
  let result = 0;

  while (encodedBuffer[index + result] >= 0x80) {
    result++;
  }

  result++; // to account for the last byte

  if (index + result > encodedBuffer.length) {
    // FIXME(sven): seems to cause false positives
    // throw new Error("integer representation too long");
  }

  return result;
}
653214
static public byte[] getBytes(String input) {

        if (null != input) {
            int length = input.length();
            byte[] output = new byte[length];
            for (int i = 0; i < length; i++) {
                output[i] = (byte) input.charAt(i);
            }
            return output;
        }
        return null;
    }
1331774
def to_bytes(s, encoding=None, errors=None):
    ''''''
    if not isinstance(s, bytes):
        return ('%s' % s).encode(encoding or 'utf-8', errors or 'strict')
    elif not encoding or encoding == 'utf-8':
        return s
    else:
        d = s.decode('utf-8')
        return d.encode(encoding, errors or 'strict')
506228
static String toDeflatedBase64(SAMLObject message) {
        requireNonNull(message, "message");

        final String messageStr;
        try {
            messageStr = nodeToString(XMLObjectSupport.marshall(message));
        } catch (MarshallingException e) {
            throw new SamlException("failed to serialize a SAML message", e);
        }

        final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
        try (DeflaterOutputStream deflaterStream =
                     new DeflaterOutputStream(Base64.getEncoder().wrap(bytesOut),
                                              new Deflater(Deflater.DEFLATED, true))) {
            deflaterStream.write(messageStr.getBytes(StandardCharsets.UTF_8));
        } catch (IOException e) {
            throw new SamlException("failed to deflate a SAML message", e);
        }
        return bytesOut.toString();
    }
1178077
def readByte(self):
        
        byte = unpack('B' if not self.signed else 'b', self.readAt(self.offset, 1))[0]
        self.offset += 1
        return byte
1107829
public static ByteBuffer bytes(String s)
	    {
	    	if(s==null)
	    		return null;
	        return ByteBuffer.wrap(s.getBytes(UTF_8));
	    }
413008
def _VarUInt64ByteSizeNoTag(uint64):
  
  if uint64 <= 0x7f: return 1
  if uint64 <= 0x3fff: return 2
  if uint64 <= 0x1fffff: return 3
  if uint64 <= 0xfffffff: return 4
  if uint64 <= 0x7ffffffff: return 5
  if uint64 <= 0x3ffffffffff: return 6
  if uint64 <= 0x1ffffffffffff: return 7
  if uint64 <= 0xffffffffffffff: return 8
  if uint64 <= 0x7fffffffffffffff: return 9
  if uint64 > UINT64_MAX:
    raise message.EncodeError('Value out of range: %d' % uint64)
  return 10
665112
def _unbytes(bytestr):
    
    return ''.join(chr(int(bytestr[k:k + 2], 16))
                   for k in range(0, len(bytestr), 2))
702447
public byte[] getMessage() {
        byte result[] = new byte[4];

        result[0] = (byte)(function >> 8);
        result[1] = (byte)(function & 0xFF);
        result[2] = (byte)(data >> 8);
        result[3] = (byte)(data & 0xFF);

        return result;
    }
751736
def _ReadPacket(self):
        
        len_char = self.ser.read(1)
        if not len_char:
            logging.error("Reading from serial port timed out.")
            return None

        data_len = ord(len_char)
        if not data_len:
            return ""
        result = self.ser.read(int(data_len))
        result = bytearray(result)
        if len(result) != data_len:
            logging.error("Length mismatch, expected %d bytes, got %d bytes.",
                          data_len, len(result))
            return None
        body = result[:-1]
        checksum = (sum(struct.unpack("B" * len(body), body)) + data_len) % 256
        if result[-1] != checksum:
            logging.error(
                "Invalid checksum from serial port! Expected %s, got %s",
                hex(checksum), hex(result[-1]))
            return None
        return result[:-1]
616524
private static byte[] decodeBytes(byte[] pInBytes) {
        byte[] decodabet = DECODABET;

        int    len34   = pInBytes.length * 3 / 4;       // Estimate on array size
        byte[] outBuff = new byte[ len34 ]; // Upper limit on size of output
        int    outBuffPosn = 0;             // Keep track of where we're writing

        byte[] b4        = new byte[4];     // Four byte buffer from source, eliminating white space
        int    b4Posn    = 0;               // Keep track of four byte input buffer
        int    i         = 0;               // Source array counter
        byte   sbiCrop   = 0;               // Low seven bits (ASCII) of input
        byte   sbiDecode = 0;               // Special value from DECODABET

        for( i = 0; i < 0 + pInBytes.length; i++ ) {  // Loop through source

            sbiCrop = (byte)(pInBytes[i] & 0x7f); // Only the low seven bits
            sbiDecode = decodabet[ sbiCrop ];   // Special value

            // White space, Equals sign, or legit Base64 character
            // Note the values such as -5 and -9 in the
            // DECODABETs at the top of the file.
            if( sbiDecode >= WHITE_SPACE_ENC )  {
                if( sbiDecode >= EQUALS_SIGN_ENC ) {
                    b4[ b4Posn++ ] = sbiCrop;           // Save non-whitespace
                    if( b4Posn > 3 ) {                  // Time to decode?
                        outBuffPosn += decode4to3( b4, 0, outBuff, outBuffPosn);
                        b4Posn = 0;

                        // If that was the equals sign, break out of 'for' loop
                        if( sbiCrop == EQUALS_SIGN ) {
                            break;
                        }
                    }
                }
            }
            else {
                // There's a bad input character in the Base64 stream.
                throw new IllegalArgumentException(String.format(
                        "Bad Base64 input character '%d' in array position %d", pInBytes[i], i ) );
            }
        }

        byte[] out = new byte[ outBuffPosn ];
        System.arraycopy( outBuff, 0, out, 0, outBuffPosn );
        return out;
    }
724157
private byte[] readContent( ZipInputStream zipInputStream ) throws IOException {
        int bufferLength = 1024;
        byte[] buffer = new byte[bufferLength];
        int n;
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        while ((n = zipInputStream.read(buffer, 0, bufferLength)) > -1) {
            baout.write(buffer, 0, n);
        }
        return baout.toByteArray();
    }