Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * ====================================================================
   * Copyright (c) 2004-2006 TMate Software Ltd.  All rights reserved.
   *
   * This software is licensed as described in the file COPYING, which
   * you should have received as part of this distribution.  The terms
   * are also available at http://svnkit.com/license.html
   * If newer versions of this license are posted there, you may use a
   * newer version instead, at your option.
  * ====================================================================
  */
 package org.tmatesoft.svn.core.internal.io.dav.http;
 
 import java.io.File;
 
 

Author(s):
TMate Software Ltd.
Version:
1.1.0
 
 class HTTPConnection implements IHTTPConnection {
     
     private static final DefaultHandler DEFAULT_SAX_HANDLER = new DefaultHandler();
     private static EntityResolver NO_ENTITY_RESOLVER = new EntityResolver() {
         public InputSource resolveEntity(String publicIdString systemIdthrows SAXExceptionIOException {
             return new InputSource(new ByteArrayInputStream(new byte[0]));
         }
     };
     
     private static final int DEFAULT_HTTP_TIMEOUT = 3600*1000;
 
     private static SAXParserFactory ourSAXParserFactory;
     private byte[] myBuffer;
     private SAXParser mySAXParser;
     private SVNURL myHost;
     private OutputStream myOutputStream;
     private InputStream myInputStream;
     private Socket mySocket;
     private SVNRepository myRepository;
     private boolean myIsSecured;
     private boolean myIsProxied;
     private boolean myIsKeepAlive;
     private boolean myIsSpoolResponse;
     private ISVNSSLManager mySSLManager;
 
     
     public HTTPConnection(SVNRepository repositorythrows SVNException {
          = repository;
          = repository.getLocation().setPath(""false);
          = "https".equalsIgnoreCase(.getProtocol());
          = repository.getOptions().keepConnection(repository);
     }
     
     public SVNURL getHost() {
        return ;
    }
    private void connect(ISVNSSLManager sslManagerthrows IOExceptionSVNException {
        SVNURL location = .getLocation();
        if ( == null || SVNSocketFactory.isSocketStale()) {
            close();
            String host = location.getHost();
            int port = location.getPort();
            
            ISVNAuthenticationManager authManager = .getAuthenticationManager();
            ISVNProxyManager proxyAuth = authManager != null ? authManager.getProxyManager(location) : null;
            if (proxyAuth != null && proxyAuth.getProxyHost() != null) {
                 = SVNSocketFactory.createPlainSocket(proxyAuth.getProxyHost(), proxyAuth.getProxyPort());
                if ( == null) {
                     = new HTTPBasicAuthentication(proxyAuth.getProxyUserName(), proxyAuth.getProxyPassword());
                }
                 = true;
                if () {
                    HTTPRequest connectRequest = new HTTPRequest();
                    connectRequest.setConnection(this);
                    connectRequest.setProxyAuthentication(.authenticate());
                    connectRequest.setForceProxyAuth(true);
                    connectRequest.dispatch("CONNECT"host + ":" + portnull, 0, 0, null);
                    HTTPStatus status = connectRequest.getStatus();
                    if (status.getCode() == .) {
                         = null;
                         = null;
                         = SVNSocketFactory.createSSLSocket(sslManagerhostport);
                        proxyAuth.acknowledgeProxyContext(truenull);
                        return;
                    }
                    SVNURL proxyURL = SVNURL.parseURIEncoded("http://" + proxyAuth.getProxyHost() + ":" + proxyAuth.getProxyPort()); 
                    SVNErrorMessage err = SVNErrorMessage.create(."{0} request failed on ''{1}''"new Object[] {"CONNECT"proxyURL});
                    proxyAuth.acknowledgeProxyContext(falseerr);
                    SVNErrorManager.error(errconnectRequest.getErrorMessage());
                }
            } else {
                 = false;
                 = null;
                 =  ? SVNSocketFactory.createSSLSocket(sslManagerhostport) : SVNSocketFactory.createPlainSocket(hostport);
            }
            if (timeout < 0) {
                timeout = ;
            }
            .setSoTimeout((inttimeout);
        }
    }
    
    public void readHeader(HTTPRequest requestthrows IOException {
        try {            
            HTTPStatus status = HTTPParser.parseStatus(is);
            HTTPHeader header = HTTPHeader.parseHeader(is);
            request.setStatus(status);
            request.setResponseHeader(header);
        } catch (ParseException e) {
            // in case of parse exception:
            // try to read remaining and log it.
            String line = HTTPParser.readLine(is);
            while(line != null && line.length() > 0) {
                line = HTTPParser.readLine(is);
            }
            throw new IOException(e.getMessage());
        } finally {
            .getDebugLog().flushStream(is);
        }
    }
    
    public SVNErrorMessage readError(HTTPRequest requestString methodString path) {
        DAVErrorHandler errorHandler = new DAVErrorHandler();
        try {
            readData(requestmethodpatherrorHandler);
        } catch (IOException e) {
            return null;
        }
        return errorHandler.getErrorMessage();
    }
    
    public void sendData(byte[] bodythrows IOException {
        try {
            getOutputStream().write(body, 0, body.length);
            getOutputStream().flush();
        } finally {
        }
    }
    
    public void sendData(InputStream sourcelong lengththrows IOException {
        try {
            byte[] buffer = getBuffer(); 
            while(length > 0) {
                int read = source.read(buffer, 0, (int) Math.min(buffer.lengthlength));
                length -= read;
                if (read > 0) {
                    getOutputStream().write(buffer, 0, read);
                } else {
                    break;
                }
            }
            getOutputStream().flush();
        } finally {
        }
    }
    
        return ;
    }
    
    public void clearAuthenticationCache() {
         = null;
         = null;
    }
    public HTTPStatus request(String methodString pathHTTPHeader headerStringBuffer bodyint ok1int ok2OutputStream dstDefaultHandler handlerthrows SVNException {
        return request(methodpathheaderbodyok1ok2dsthandlernull);
    }
    public HTTPStatus request(String methodString pathHTTPHeader headerStringBuffer bodyint ok1int ok2OutputStream dstDefaultHandler handlerSVNErrorMessage contextthrows SVNException {
        byte[] buffer = null;
        if (body != null) {
            try {
                buffer = body.toString().getBytes("UTF-8");
            } catch (UnsupportedEncodingException e) {
                buffer = body.toString().getBytes();
            }
        } 
        return request(methodpathheaderbuffer != null ? new ByteArrayInputStream(buffer) : nullok1ok2dsthandlercontext);
    }
    public HTTPStatus request(String methodString pathHTTPHeader headerInputStream bodyint ok1int ok2OutputStream dstDefaultHandler handlerthrows SVNException {
        return request(methodpathheaderbodyok1ok2dsthandlernull);
    }
    
    public HTTPStatus request(String methodString pathHTTPHeader headerInputStream bodyint ok1int ok2OutputStream dstDefaultHandler handlerSVNErrorMessage contextthrows SVNException {
        if ("".equals(path) || path == null) {
            path = "/";
        }
        
        if ( != null) {
            .setChallengeParameter("methodname"method);
            .setChallengeParameter("uri"path);
        }
        
        // 1. prompt for ssl client cert if needed, if cancelled - throw cancellation exception.
        ISVNSSLManager sslManager =  != null ?  : promptSSLClientCertificate(true);
        String sslRealm = "<" + .getProtocol() + "://" + .getHost() + ":" + .getPort() + ">";
        SVNAuthentication httpAuth = ;
        boolean isAuthForced = .getAuthenticationManager() != null ? .getAuthenticationManager().isAuthenticationForced() : false;
        if (httpAuth == null && isAuthForced) {
            httpAuth = .getAuthenticationManager().getFirstAuthentication(.sslRealmnull);
            .setChallengeParameter("methodname"method);
            .setChallengeParameter("uri"path);
        } 
        String realm = null;
        // 2. create request instance.
        HTTPRequest request = new HTTPRequest();
        request.setConnection(this);
        request.setKeepAlive();
        request.setRequestBody(body);
        request.setResponseHandler(handler);
        request.setResponseStream(dst);
        
        SVNErrorMessage err = null;
        while (true) {
            HTTPStatus status = null;
            try {
                err = null;
                connect(sslManager);
                request.reset();
                request.setProxied();
                request.setSecured();
                if ( != null) {
                    request.setProxyAuthentication(.authenticate());
                }
                if (httpAuth != null &&  != null) {
                    String authResponse = .authenticate();
                    request.setAuthentication(authResponse);
                }
                request.dispatch(methodpathheaderok1ok2context);
                status = request.getStatus();
            } catch (SSLHandshakeException ssl) {
                .getDebugLog().info(ssl);
                if (sslManager != null) {
                    SVNSSLAuthentication sslAuth = sslManager.getClientAuthentication();
                    if (sslAuth != null) {
                        close();
                        SVNErrorMessage sslErr = SVNErrorMessage.create(."SSL handshake failed: ''{0}''"ssl.getMessage());
                        .getAuthenticationManager().acknowledgeAuthentication(false.sslRealmsslErrsslAuth);
                        sslManager = promptSSLClientCertificate(false);
                        continue;
                    }
                }
                err = SVNErrorMessage.create(.ssl.getMessage());
            } catch (IOException e) {
                .getDebugLog().info(e);
                if (e instanceof SocketTimeoutException) {
                    err = SVNErrorMessage.create(."timed out waiting for server");
                } else {
                    if (sslManager != null && sslManager.isClientCertPromptRequired()) {
                        SVNSSLAuthentication sslAuth = sslManager.getClientAuthentication();
                        if (sslAuth != null) {
                            close();
                            SVNErrorMessage sslErr = SVNErrorMessage.create(."SSL handshake failed: ''{0}''"e.getMessage());
                            .getAuthenticationManager().acknowledgeAuthentication(false.sslRealmsslErrsslAuth);
                            sslManager = promptSSLClientCertificate(false);
                            continue;
                        }
                    }
                    err = SVNErrorMessage.create(.e.getMessage());
                }
            } catch (SVNException e) {
                .getDebugLog().info(e);
                // force connection close on SVNException 
                // (could be thrown by user's auth manager methods).
                close();
                throw e;
            } finally {
                finishResponse(request);                
            }
            if (err != null) {
                close();
                if (sslManager != null) {
                    sslManager.acknowledgeSSLContext(falseerr);
                }
                break;
            }
            if (sslManager != null) {
                sslManager.acknowledgeSSLContext(truenull);
                SVNSSLAuthentication sslAuth = sslManager.getClientAuthentication();
                if (sslAuth != null) {
                     = sslManager;
                    .getAuthenticationManager().acknowledgeAuthentication(true.sslRealmnullsslAuth);
                }
            }
            if (status.getCode() == .) {
                 = null;
                close();
                err = request.getErrorMessage();
            } else if ( && status.getCode() == .) {
                Collection proxyAuthHeaders = request.getResponseHeader().getHeaderValues(.);
                boolean retry = false;
                if (!HTTPAuthentication.isSchemeSupportedByServer(.getAuthenticationScheme(), proxyAuthHeaders)) {
                    retry = true;
                }
                try {
                     = HTTPAuthentication.parseAuthParameters(proxyAuthHeaders); 
                } catch (SVNException svne) {
                    .getDebugLog().info(svne);
                    err = svne.getErrorMessage(); 
                    break;
                }
                if (retry) {
                    close();
                    continue;
                }
                if ( instanceof HTTPNTLMAuthentication) {
                    HTTPNTLMAuthentication ntlmProxyAuth = (HTTPNTLMAuthentication);
                    if (ntlmProxyAuth.isInType3State()) {
                        continue;
                    }
                }
                err = SVNErrorMessage.create(."HTTP proxy authorization cancelled");
                SVNURL location = .getLocation();
                ISVNAuthenticationManager authManager = .getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(falseerr);
                }
                close();
                break;
            } else if (status.getCode() == .) {
                Collection authHeaderValues = request.getResponseHeader().getHeaderValues(.);
                if (authHeaderValues == null || authHeaderValues.size() == 0) {
                    err = request.getErrorMessage();
                    status.setError(SVNErrorMessage.create(.err.getMessageTemplate(), err.getRelatedObjects()));
                    if ("LOCK".equalsIgnoreCase(method)) {
                        status.getError().setChildErrorMessage(SVNErrorMessage.create(.
                                "Probably you are trying to lock file in repository that only allows anonymous access"));
                    }
                    SVNErrorManager.error(status.getError());
                    return status;  
                }
                //we should work around a situation when a server
                //does not support Basic authentication while we're 
                //forcing it, credentials should not be immediately
                //thrown away
                boolean skip = false;
                isAuthForced = .getAuthenticationManager() != null ? .getAuthenticationManager().isAuthenticationForced() : false;
                if (isAuthForced) {
                    if (httpAuth != null &&  != null && !HTTPAuthentication.isSchemeSupportedByServer(.getAuthenticationScheme(), authHeaderValues)) {
                        skip = true;
                    }
                }
                
                try {
                     = HTTPAuthentication.parseAuthParameters(authHeaderValues); 
                } catch (SVNException svne) {
                    err = svne.getErrorMessage(); 
                    break;
                }
                .setChallengeParameter("methodname"method);
                .setChallengeParameter("uri"path);
                
                if (skip) {
                    close();
                    continue;
                }
                
                if ( instanceof HTTPNTLMAuthentication) {
                    HTTPNTLMAuthentication ntlmAuth = (HTTPNTLMAuthentication);
                    if (ntlmAuth.isInType3State()) {
                        continue;
                    }
                }
                 = null;
                close();
                
                ISVNAuthenticationManager authManager = .getAuthenticationManager();
                if (authManager == null) {
                    err = request.getErrorMessage();
                    break;
                }
                realm = .getChallengeParameter("realm");
                realm = realm == null ? "" : " " + realm;
                realm = "<" + .getProtocol() + "://" + .getHost() + ":" + .getPort() + ">" + realm;
                if (httpAuth == null) {
                    httpAuth = authManager.getFirstAuthentication(.realm.getLocation());
                } else {
                    authManager.acknowledgeAuthentication(false.realmrequest.getErrorMessage(), httpAuth);
                    httpAuth = authManager.getNextAuthentication(.realm.getLocation());
                }
                if (httpAuth == null) {
                    err = SVNErrorMessage.create(."HTTP authorization cancelled");
                    break;
                }
                .setCredentials((SVNPasswordAuthentication)httpAuth);
                continue;
            } else if (status.getCode() == . || status.getCode() == .) {
                close();
                String newLocation = request.getResponseHeader().getFirstHeaderValue(.);
                if (newLocation == null) {
                    err = request.getErrorMessage();
                    break;
                }
                int hostIndex = newLocation.indexOf("://");
                if (hostIndex > 0) {
                    hostIndex += 3;
                    hostIndex = newLocation.indexOf("/"hostIndex);
                }
                if (hostIndex > 0 && hostIndex < newLocation.length()) {
                    String newPath = newLocation.substring(hostIndex);
                    if (newPath.endsWith("/") &&
                            !newPath.endsWith("//") && !path.endsWith("/") &&
                            newPath.substring(0, newPath.length() - 1).equals(path)) {
                        path += "//";
                        continue;
                    }
                }
                err = request.getErrorMessage();
            } else if (request.getErrorMessage() != null) {
                err = request.getErrorMessage();
            }
            if (err != null) {
                break;
            }
            
            if () {
                SVNURL location = .getLocation();
                ISVNAuthenticationManager authManager = .getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(truenull);
                }
            }
            
            if (httpAuth != null && realm != null && .getAuthenticationManager() != null) {
                .getAuthenticationManager().acknowledgeAuthentication(true.realmnullhttpAuth);
            }
             = httpAuth;
            status.setHeader(request.getResponseHeader());
            return status;
        }
        // force close on error that was not processed before.
        // these are errors that has no relation to http status (processing error or cancellation).
        close();
        if (err != null && err.getErrorCode().getCategory() != . &&
            err.getErrorCode() != .) {
            SVNErrorManager.error(err);
        }
        // err2 is another default context...
        .getDebugLog().info(err.getMessage());
        .getDebugLog().info(new Exception());
        
        SVNErrorMessage err2 = SVNErrorMessage.create(."{0} request failed on ''{1}''"new Object[] {methodpath});
        SVNErrorManager.error(err2err);
        return null;
    }
    private ISVNSSLManager promptSSLClientCertificate(boolean firstAuththrows SVNException {
        SVNURL location = .getLocation();
        ISVNSSLManager sslManager = null;
        SVNSSLAuthentication sslAuth = null;
        String sslRealm = "<" + location.getProtocol() + "://" + location.getHost() + ":" + location.getPort() + ">";
        if () {
            sslManager = authManager != null ? authManager.getSSLManager(location) : null;
        }
        if (authManager != null && sslManager != null && sslManager.isClientCertPromptRequired()) {
            if (firstAuth) {
                sslAuth = (SVNSSLAuthenticationauthManager.getFirstAuthentication(.sslRealmlocation);
            } else {
                sslAuth = (SVNSSLAuthenticationauthManager.getNextAuthentication(.sslRealmlocation);
            }
            if (sslAuth == null) {
                SVNErrorManager.cancel("SSL authentication with client certificate cancelled");
            }
            sslManager.setClientAuthentication(sslAuth);
        }
        return sslManager;
    }
    public SVNErrorMessage readData(HTTPRequest requestOutputStream dstthrows IOException {
        InputStream stream = createInputStream(request.getResponseHeader(), getInputStream());
        byte[] buffer = getBuffer();
        boolean willCloseConnection = false;
        try {
            while (true) {
                int count = stream.read(buffer);
                if (count <= 0) {
                    break;
                }
                if (dst != null) {
                    dst.write(buffer, 0, count);
                }
            }
        } catch (IOException e) {
            willCloseConnection = true;
            if (e.getCause() instanceof SVNException) {
                return ((SVNExceptione.getCause()).getErrorMessage();
            }
            throw e;
        } finally {
            if (!willCloseConnection) {
                SVNFileUtil.closeFile(stream);
            }
            .getDebugLog().flushStream(stream);
        }
        return null;
    }
    
    public SVNErrorMessage readData(HTTPRequest requestString methodString pathDefaultHandler handlerthrows IOException {
        InputStream is = null
        File tmpFile = null
        SVNErrorMessage err = null;
        boolean closeStream = ;
        try {
            if () {
                OutputStream dst = null;
                try {
                    tmpFile = SVNFileUtil.createTempFile(".svnkit"".spool");
                    dst = SVNFileUtil.openFileForWriting(tmpFile);
                    // this will exhaust http stream anyway.
                    err = readData(requestdst);
                    closeStream |= err != null;
                    if (err != null) {
                        return err;
                    }
                    // this stream always have to be closed.
                    is = SVNFileUtil.openFileForReading(tmpFile);
                } catch (SVNException e) {
                    return e.getErrorMessage();
                } finally {
                    SVNFileUtil.closeFile(dst);
                }
            } else {
                is = createInputStream(request.getResponseHeader(), getInputStream());
            }
            // this will not close is stream.
            err = readData(ismethodpathhandler);
            closeStream |= err != null;
        } catch (IOException e) {
            closeStream = true;
            throw e;
        } finally {
            if () {
                // always close spooled stream.
                SVNFileUtil.closeFile(is);
            } else if (err == null && !hasToCloseConnection(request.getResponseHeader())) {
                // exhaust stream if connection is not about to be closed.
                SVNFileUtil.closeFile(is);
            }
            if (tmpFile != null) {
                try {
                    SVNFileUtil.deleteFile(tmpFile);
                } catch (SVNException e) {
                    throw new IOException(e.getMessage());
                }
            }
             = false;
        }
        return err;
    }
        try {
            if ( == null) {
                 = getSAXParserFactory().newSAXParser();
            }
            XMLReader reader = new XMLReader(is);
            while (!reader.isClosed()) {
                org.xml.sax.XMLReader xmlReader = .getXMLReader();
                xmlReader.setContentHandler(handler);
                xmlReader.setDTDHandler(handler);
                xmlReader.setErrorHandler(handler);
                xmlReader.setEntityResolver();
                xmlReader.parse(new InputSource(reader));
            }
        } catch (SAXException e) {
            if (e instanceof SAXParseException) {
                if (handler instanceof DAVErrorHandler) {
                    // failed to read svn-specific error, return null.
                    return null;
                }
            } else if (e.getException() instanceof SVNException) {
                return ((SVNExceptione.getException()).getErrorMessage();
            } else if (e.getCause() instanceof SVNException) {
                return ((SVNExceptione.getCause()).getErrorMessage();
            } 
            return SVNErrorMessage.create(."Processing {0} request response failed: {1} ({2}) ",  new Object[] {methode.getMessage(), path});
        } catch (ParserConfigurationException e) {
            return SVNErrorMessage.create(."XML parser configuration error while processing {0} request response: {1} ({2}) ",  new Object[] {methode.getMessage(), path});
        } catch (EOFException e) {
            // skip it.
        } finally {
            if ( != null) {
                // to avoid memory leaks when connection is cached.
                org.xml.sax.XMLReader xmlReader = null;
                try {
                    xmlReader = .getXMLReader();
                } catch (SAXException e) {
                }
                if (xmlReader != null) {
                    xmlReader.setContentHandler();
                    xmlReader.setDTDHandler();
                    xmlReader.setErrorHandler();
                    xmlReader.setEntityResolver();
                }
            }
            .getDebugLog().flushStream(is);
        }
        return null;
    }
    
    public void skipData(HTTPRequest requestthrows IOException {
        if (hasToCloseConnection(request.getResponseHeader())) {
            return;
        }
        InputStream is = createInputStream(request.getResponseHeader(), getInputStream());
        while(is.skip(2048) > 0);        
    }
    public void close() {
        if ( != null) {
            if ( != null) {
                try {
                    .close();
                } catch (IOException e) {}
            }
            if ( != null) {
                try {
                    .flush();
                } catch (IOException e) {}
            }
            if ( != null) {
                try {
                    .close();
                } catch (IOException e) {}
            }
            try {
                .close();
            } catch (IOException e) {}
             = null;
             = null;
             = null;
        }
    }
    private byte[] getBuffer() {
        if ( == null) {
             = new byte[32*1024];
        }
        return ;
    }
    private InputStream getInputStream() throws IOException {
        if ( == null) {
            if ( == null) {
                return null;
            }
             = new BufferedInputStream(.getInputStream(), 2048);
        }
        return ;
    }
    private OutputStream getOutputStream() throws IOException {
        if ( == null) {
            if ( == null) {
                return null;
            }
             = new BufferedOutputStream(.getOutputStream(), 2048);
        }
        return ;
    }
    private void finishResponse(HTTPRequest request) {
        if ( != null) {
            try {
                .flush();
            } catch (IOException ex) {
            }
        }
        HTTPHeader header = request != null ? request.getResponseHeader() : null;
        if (hasToCloseConnection(header)) {
            close();
        }
    }
    
    private static boolean hasToCloseConnection(HTTPHeader header) {
        if (header == null || 
                "close".equalsIgnoreCase(header.getFirstHeaderValue(.)) || 
                "close".equalsIgnoreCase(header.getFirstHeaderValue(.))) {
            return true;
        }
        return false;
    }
    
    private InputStream createInputStream(HTTPHeader readHeaderInputStream isthrows IOException {
        if ("chunked".equalsIgnoreCase(readHeader.getFirstHeaderValue(.))) {
            is = new ChunkedInputStream(is);
        } else if (readHeader.getFirstHeaderValue(.) != null) {
            is = new FixedSizeInputStream(is, Long.parseLong(readHeader.getFirstHeaderValue(.).toString()));
        } else if (!hasToCloseConnection(readHeader)) {
            // no content length and no valid transfer-encoding!
            // consider as empty response.
            // but only when there is no "Connection: close" or "Proxy-Connection: close" header,
            // in that case just return "is". 
            // skipData will not read that as it should also analyze "close" instruction.
            
            // return empty stream. 
            // and force connection close? (not to read garbage on the next request).
            is = new FixedSizeInputStream(is, 0);
            // this will force connection to close.
            readHeader.setHeaderValue(."close");
        } 
        
        if ("gzip".equals(readHeader.getFirstHeaderValue(.))) {
            is = new GZIPInputStream(is);
        }
        return .getDebugLog().createLogStream(is);
    }
    private static synchronized SAXParserFactory getSAXParserFactory() throws FactoryConfigurationError {
        if ( == null) {
             = SAXParserFactory.newInstance();
            try {
                .setFeature("http://xml.org/sax/features/namespaces"true);
            } catch (SAXNotRecognizedException e) {
            } catch (SAXNotSupportedException e) {
            } catch (ParserConfigurationException e) {
            }
            try {
                .setFeature("http://xml.org/sax/features/validation"false);
            } catch (SAXNotRecognizedException e) {
            } catch (SAXNotSupportedException e) {
            } catch (ParserConfigurationException e) {
            }
            try {
                .setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd"false);
            } catch (SAXNotRecognizedException e) {
            } catch (SAXNotSupportedException e) {
            } catch (ParserConfigurationException e) {
            }
            .setNamespaceAware(true);
            .setValidating(false);
        }
        return ;
    }
    public void setSpoolResponse(boolean spoolResponse) {
         = spoolResponse;
    }
New to GrepCode? Check out our FAQ X