Java 类org.apache.commons.httpclient.util.ExceptionUtil 实例源码

项目:lib-commons-httpclient    文件:ChunkedInputStream.java   
/**
 * Reads and stores the Trailer headers.
 * @throws IOException If an IO problem occurs
 */
private void parseTrailerHeaders() throws IOException {
    Header[] footers = null;
    try {
        String charset = "US-ASCII";
        if (this.method != null) {
            charset = this.method.getParams().getHttpElementCharset();
        }
        footers = HttpParser.parseHeaders(in, charset);
    } catch(HttpException e) {
        LOG.error("Error parsing trailer headers", e);
        IOException ioe = new IOException(e.getMessage());
        ExceptionUtil.initCause(ioe, e); 
        throw ioe;
    }
    if (this.method != null) {
        for (int i = 0; i < footers.length; i++) {
            this.method.addResponseFooter(footers[i]);
        }
    }
}
项目:httpclient3-ntml    文件:ChunkedInputStream.java   
/**
 * Reads and stores the Trailer headers.
 * @throws IOException If an IO problem occurs
 */
private void parseTrailerHeaders() throws IOException {
    Header[] footers = null;
    try {
        String charset = "US-ASCII";
        if (this.method != null) {
            charset = this.method.getParams().getHttpElementCharset();
        }
        footers = HttpParser.parseHeaders(in, charset);
    } catch(HttpException e) {
        LOG.error("Error parsing trailer headers", e);
        IOException ioe = new IOException(e.getMessage());
        ExceptionUtil.initCause(ioe, e); 
        throw ioe;
    }
    if (this.method != null) {
        for (int i = 0; i < footers.length; i++) {
            this.method.addResponseFooter(footers[i]);
        }
    }
}
项目:lib-commons-httpclient    文件:HttpConnection.java   
/**
 * Tests if input data becomes available within the given period time in milliseconds.
 * 
 * @param timeout The number milliseconds to wait for input data to become available 
 * @return boolean <tt>true</tt> if input data is availble, 
 *                 <tt>false</tt> otherwise.
 * 
 * @throws IOException If an IO problem occurs
 * @throws IllegalStateException If the connection isn't open.
 */
public boolean isResponseAvailable(int timeout) 
    throws IOException {
    LOG.trace("enter HttpConnection.isResponseAvailable(int)");
    assertOpen();
    boolean result = false;
    if (this.inputStream.available() > 0) {
        result = true;
    } else {
        try {
            this.socket.setSoTimeout(timeout);
            inputStream.mark(1);
            int byteRead = inputStream.read();
            if (byteRead != -1) {
                inputStream.reset();
                LOG.debug("Input data available");
                result = true;
            } else {
                LOG.debug("Input data not available");
            }
        } catch (InterruptedIOException e) {
            if (!ExceptionUtil.isSocketTimeoutException(e)) {
                throw e;
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug("Input data not available after " + timeout + " ms");
            }
        } finally {
            try {
                socket.setSoTimeout(this.params.getSoTimeout());
            } catch (IOException ioe) {
                LOG.debug("An error ocurred while resetting soTimeout, we will assume that"
                    + " no response is available.",
                    ioe);
                result = false;
            }
        }
    }
    return result;
}
项目:http4e    文件:HttpConnection.java   
/**
 * Tests if input data becomes available within the given period time in milliseconds.
 * 
 * @param timeout The number milliseconds to wait for input data to become available 
 * @return boolean <tt>true</tt> if input data is availble, 
 *                 <tt>false</tt> otherwise.
 * 
 * @throws IOException If an IO problem occurs
 * @throws IllegalStateException If the connection isn't open.
 */
public boolean isResponseAvailable(int timeout) 
    throws IOException {
    LOG.trace("enter HttpConnection.isResponseAvailable(int)");
    assertOpen();
    boolean result = false;
    if (this.inputStream.available() > 0) {
        result = true;
    } else {
        try {
            this.socket.setSoTimeout(timeout);
            inputStream.mark(1);
            int byteRead = inputStream.read();
            if (byteRead != -1) {
                inputStream.reset();
                LOG.debug("Input data available");
                result = true;
            } else {
                LOG.debug("Input data not available");
            }
        } catch (InterruptedIOException e) {
            if (!ExceptionUtil.isSocketTimeoutException(e)) {
                throw e;
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug("Input data not available after " + timeout + " ms");
            }
        } finally {
            try {
                socket.setSoTimeout(this.params.getSoTimeout());
            } catch (IOException ioe) {
                LOG.debug("An error ocurred while resetting soTimeout, we will assume that"
                    + " no response is available.",
                    ioe);
                result = false;
            }
        }
    }
    return result;
}
项目:httpclient3-ntml    文件:HttpConnection.java   
/**
 * Tests if input data becomes available within the given period time in milliseconds.
 * 
 * @param timeout The number milliseconds to wait for input data to become available 
 * @return boolean <tt>true</tt> if input data is availble, 
 *                 <tt>false</tt> otherwise.
 * 
 * @throws IOException If an IO problem occurs
 * @throws IllegalStateException If the connection isn't open.
 */
public boolean isResponseAvailable(int timeout) 
    throws IOException {
    LOG.trace("enter HttpConnection.isResponseAvailable(int)");
    assertOpen();
    boolean result = false;
    if (this.inputStream.available() > 0) {
        result = true;
    } else {
        try {
            this.socket.setSoTimeout(timeout);
            inputStream.mark(1);
            int byteRead = inputStream.read();
            if (byteRead != -1) {
                inputStream.reset();
                LOG.debug("Input data available");
                result = true;
            } else {
                LOG.debug("Input data not available");
            }
        } catch (InterruptedIOException e) {
            if (!ExceptionUtil.isSocketTimeoutException(e)) {
                throw e;
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug("Input data not available after " + timeout + " ms");
            }
        } finally {
            try {
                socket.setSoTimeout(this.params.getSoTimeout());
            } catch (IOException ioe) {
                LOG.debug("An error ocurred while resetting soTimeout, we will assume that"
                    + " no response is available.",
                    ioe);
                result = false;
            }
        }
    }
    return result;
}
项目:lib-commons-httpclient    文件:NoHttpResponseException.java   
/**
 * Creates a new NoHttpResponseException with the specified detail message and cause.
 *
 * @param message the exception detail message
 * @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
 * if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
 * 
 * @since 3.0
 */
public NoHttpResponseException(String message, Throwable cause) {
    super(message);
    // If we're running on JDK 1.4 or later, tell Throwable what the cause was
    ExceptionUtil.initCause(this, cause);
}
项目:lib-commons-httpclient    文件:ConnectTimeoutException.java   
/**
 * Creates a new ConnectTimeoutException with the specified detail message and cause.
 * 
 * @param message the exception detail message
 * @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
 * if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
 */
public ConnectTimeoutException(String message, Throwable cause) {
    super(message);
    // If we're running on JDK 1.4 or later, tell Throwable what the cause was
    ExceptionUtil.initCause(this, cause);
}
项目:lib-commons-httpclient    文件:ProxyDetectionException.java   
/**
 * Creates a new ProxyDetectionException with the specified detail message 
 * and cause.
 * 
 * @param message the exception detail message
 * @param cause the <tt>Throwable</tt> that caused this exception, or 
 *              <tt>null</tt> if the cause is unavailable, unknown, or not 
 *              a <tt>Throwable</tt>
 */
public ProxyDetectionException(String message, Throwable cause) {
    super(message);
    ExceptionUtil.initCause(this, cause);
}
项目:httpclient3-ntml    文件:NoHttpResponseException.java   
/**
 * Creates a new NoHttpResponseException with the specified detail message and cause.
 *
 * @param message the exception detail message
 * @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
 * if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
 * 
 * @since 3.0
 */
public NoHttpResponseException(String message, Throwable cause) {
    super(message);
    // If we're running on JDK 1.4 or later, tell Throwable what the cause was
    ExceptionUtil.initCause(this, cause);
}
项目:httpclient3-ntml    文件:ConnectTimeoutException.java   
/**
 * Creates a new ConnectTimeoutException with the specified detail message and cause.
 * 
 * @param message the exception detail message
 * @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
 * if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
 */
public ConnectTimeoutException(String message, Throwable cause) {
    super(message);
    // If we're running on JDK 1.4 or later, tell Throwable what the cause was
    ExceptionUtil.initCause(this, cause);
}
项目:httpclient3-ntml    文件:ProxyDetectionException.java   
/**
 * Creates a new ProxyDetectionException with the specified detail message 
 * and cause.
 * 
 * @param message the exception detail message
 * @param cause the <tt>Throwable</tt> that caused this exception, or 
 *              <tt>null</tt> if the cause is unavailable, unknown, or not 
 *              a <tt>Throwable</tt>
 */
public ProxyDetectionException(String message, Throwable cause) {
    super(message);
    ExceptionUtil.initCause(this, cause);
}