org.apache.commons.httpclient.HttpConnection.isStale()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中org.apache.commons.httpclient.HttpConnection.isStale()方法的一些代码示例,展示了HttpConnection.isStale()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpConnection.isStale()方法的具体详情如下:
包路径:org.apache.commons.httpclient.HttpConnection
类名称:HttpConnection
方法名:isStale

HttpConnection.isStale介绍

[英]Determines whether this connection is "stale", which is to say that either it is no longer open, or an attempt to read the connection would fail.

Unfortunately, due to the limitations of the JREs prior to 1.4, it is not possible to test a connection to see if both the read and write channels are open - except by reading and writing. This leads to a difficulty when some connections leave the "write" channel open, but close the read channel and ignore the request. This function attempts to ameliorate that problem by doing a test read, assuming that the caller will be doing a write followed by a read, rather than the other way around.

To avoid side-effects, the underlying connection is wrapped by a BufferedInputStream, so although data might be read, what is visible to clients of the connection will not change with this call.
[中]确定此连接是否“过时”,也就是说它不再打开,或者读取连接的尝试将失败。
不幸的是,由于1.4之前的JRE的限制,不可能测试连接以查看读和写通道是否都打开-除非通过读和写。当某些连接保持“写入”通道打开,但关闭读取通道并忽略请求时,这会导致一个困难。此函数尝试通过执行测试读取来改善该问题,假设调用方将先执行写入,然后执行读取,而不是相反。
为了避免副作用,底层连接由BufferedInputStream包装,因此尽管可能会读取数据,但连接的客户端可见的内容不会随此调用而改变。

代码示例

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Closes the connection if stale.
 * 
 * @return <code>true</code> if the connection was stale and therefore closed, 
 * <code>false</code> otherwise.
 * 
 * @see #isStale()
 * 
 * @since 3.0
 */
public boolean closeIfStale() throws IOException {
  if (isOpen && isStale()) {
    LOG.debug("Connection is stale, closing...");
    close();
    return true;
  }
  return false;
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Closes the connection if stale.
 * 
 * @return <code>true</code> if the connection was stale and therefore closed, 
 * <code>false</code> otherwise.
 * 
 * @see #isStale()
 * 
 * @since 3.0
 */
public boolean closeIfStale() throws IOException {
  if (isOpen && isStale()) {
    LOG.debug("Connection is stale, closing...");
    close();
    return true;
  }
  return false;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Closes the connection if stale.
 * 
 * @return <code>true</code> if the connection was stale and therefore closed, 
 * <code>false</code> otherwise.
 * 
 * @see #isStale()
 * 
 * @since 3.0
 */
public boolean closeIfStale() throws IOException {
  if (isOpen && isStale()) {
    LOG.debug("Connection is stale, closing...");
    close();
    return true;
  }
  return false;
}

代码示例来源:origin: org.apache.commons/httpclient

/**
 * Closes the connection if stale.
 * 
 * @return <code>true</code> if the connection was stale and therefore closed, 
 * <code>false</code> otherwise.
 * 
 * @see #isStale()
 * 
 * @since 3.0
 */
public boolean closeIfStale() throws IOException {
  if (isOpen && isStale()) {
    LOG.debug("Connection is stale, closing...");
    close();
    return true;
  }
  return false;
}

代码示例来源:origin: org.mule.transports/mule-transport-http

/**
 * Closes the connection if stale.
 *
 * @return <code>true</code> if the connection was stale and therefore closed, 
 * <code>false</code> otherwise.
 *
 * @see #isStale()
 *
 * @since 3.0
 */
public boolean closeIfStale() throws IOException {
  if (isOpen && isStale()) {
    LOG.debug("Connection is stale, closing...");
    close();
    return true;
  }
  return false;
}

代码示例来源:origin: org.zaproxy/zap

/**
 * Closes the connection if stale.
 * 
 * @return <code>true</code> if the connection was stale and therefore closed, 
 * <code>false</code> otherwise.
 * 
 * @see #isStale()
 * 
 * @since 3.0
 */
public boolean closeIfStale() throws IOException {
  if (isOpen && isStale()) {
    LOG.debug("Connection is stale, closing...");
    close();
    return true;
  }
  return false;
}

代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient

/**
 * Closes the connection if stale.
 * 
 * @return <code>true</code> if the connection was stale and therefore closed, 
 * <code>false</code> otherwise.
 * 
 * @see #isStale()
 * 
 * @since 3.0
 */
public boolean closeIfStale() throws IOException {
  if (isOpen && isStale()) {
    LOG.debug("Connection is stale, closing...");
    close();
    return true;
  }
  return false;
}

相关文章

微信公众号

最新文章

更多

HttpConnection类方法