public void readResponse(InputStream in, long length) throws IOException {
        byte []data;
        
        if(length == -1) {        
            final int CHUNKSIZE=2048;
            ByteArrayOutputStream baos = new ByteArrayOutputStream(4*CHUNKSIZE);        
            byte[] chunkbuf = new byte[CHUNKSIZE];
            int cnt = 0;
            do {
                int n = in.read(chunkbuf, 0, CHUNKSIZE);
                if (n != -1) {
                    baos.write(chunkbuf, 0, n);
                    cnt += n;
                }
                else {
                    break;
                }
            } while (true);
            
            data = baos.toByteArray();
            
        } else {
            data = new byte[(int)length];
            for (int bytesRead = 0; bytesRead < data.length;) {
                int read = in.read(data, bytesRead, (data.length - bytesRead));
                if(read == -1) {
                    throw new EOFException();
                }
                bytesRead += read;
            }
        }
//        BitBuffer buffer = new BitBuffer(data); 
//        String paramString = buffer.nextString();                
//        int nbrOfBytes = (int) buffer.nextInt();
//        byte []tiledata = buffer.nextByteArray(nbrOfBytes);
//        
//        if (paramString.equals(m_paramString)) {
//            m_tileMapReqlistener.requestReceived(paramString,tiledata, false);
//        } else {
//            if(LOG.isError()) {
//                LOG.warn("TileMapRequest.readResponse()", "bad response " + paramString + " instead of " +m_paramString);
//            }
//            m_tileMapReqlistener.requestFailed(new String[]{m_paramString});
//        }
        m_tileMapReqlistener.requestReceived(m_paramString, data, false);
        m_networkHandler.setHasOutgoingRequest(false);
        m_networkHandler.resetExponentialBackoff();
    }