public void readResponse(InputStream in, long length) throws IOException {
        if(LOG.isTrace()) {
            byte[] data = new byte[1024];
            int off = 0;
            int len = 0;
            int n;
            while ( (n = in.read(data,off,data.length - off)) >= 0) {
                len += n;
                off += n;
                if (len == data.length) {
                    byte[] tmp = data;
                    data = new byte[data.length*4/3+ 4];
                    System.arraycopy(tmp, 0, data, 0, len);
                }
            } 
            LOG.trace("MC2Document.readResponse()", new String(data,0,len));
            in = new ByteArrayInputStream(data,0,len);
        }
        
        if(LOG.isDebug()) {
            LOG.debug("MC2Document.readResponse()", "Reading XML response");
        }
        
        MC2ParserImpl mc2parser = new MC2ParserImpl(in, null);
        try {
            ServerError error = mc2parser.parseDocumentStart(m_storage);
            if(error != null) {
                // all requests where completely void
                error(error);
                return;
            }
        } catch (MC2ParserException e1) {
            error(new UnexpectedError("Could not parse document start", e1));
            throw new IOException("Could not parse document start");
        }
        
        try {
            // parse all that we can find
            parseRequests(mc2parser);
        } catch (MC2ParserException ex) {
            if(LOG.isError()) {
                LOG.error("MC2Document.readResponse()", ex);
            }
            error(new UnexpectedError("Caught exception while parsing document", ex));
        }
    }