okhttp3.internal.Util.discard()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(204)

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

Util.discard介绍

[英]Attempts to exhaust source, returning true if successful. This is useful when reading a complete source is helpful, such as when doing so completes a cache body or frees a socket connection for reuse.
[中]尝试耗尽源,如果成功,则返回true。当读取完整的源代码时,这很有用,例如这样做可以完成缓存体或释放套接字连接以供重用。

代码示例

代码示例来源:origin: square/okhttp

@Override public void close() throws IOException {
  if (closed) return;
  if (bytesRemaining != 0 && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false, null);
  }
  closed = true;
 }
}

代码示例来源:origin: square/okhttp

@Override public void close() throws IOException {
  if (closed) return;
  if (hasMoreChunks && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false, null);
  }
  closed = true;
 }
}

代码示例来源:origin: square/okhttp

@Override public void close() throws IOException {
  if (!cacheRequestClosed
    && !discard(this, HttpCodec.DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   cacheRequestClosed = true;
   cacheRequest.abort();
  }
  source.close();
 }
};

代码示例来源:origin: com.squareup.okhttp3/okhttp

@Override public void close() throws IOException {
  if (closed) return;
  if (bytesRemaining != 0 && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false, null);
  }
  closed = true;
 }
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

@Override public void close() throws IOException {
  if (closed) return;
  if (hasMoreChunks && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false, null);
  }
  closed = true;
 }
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

@Override public void close() throws IOException {
  if (!cacheRequestClosed
    && !discard(this, HttpCodec.DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   cacheRequestClosed = true;
   cacheRequest.abort();
  }
  source.close();
 }
};

代码示例来源:origin: apollographql/apollo-android

@Override public void close() throws IOException {
 if (closed) return;
 closed = true;
 if (discard(this, HttpCodec.DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
  responseBodySource.close();
  commitCache();
 } else {
  responseBodySource.close();
  abortCacheQuietly();
 }
}

代码示例来源:origin: huxq17/SwipeCardsView

@Override public void close() throws IOException {
  if (closed) return;
  if (hasMoreChunks && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   unexpectedEndOfInput();
  }
  closed = true;
 }
}

代码示例来源:origin: duzechao/OKHttpUtils

@Override public void close() throws IOException {
  if (closed) return;
  if (bytesRemaining != 0 && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false);
  }
  closed = true;
 }
}

代码示例来源:origin: apache/servicemix-bundles

@Override public void close() throws IOException {
  if (closed) return;
  if (hasMoreChunks && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false, null);
  }
  closed = true;
 }
}

代码示例来源:origin: duzechao/OKHttpUtils

@Override public void close() throws IOException {
  if (closed) return;
  if (hasMoreChunks && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false);
  }
  closed = true;
 }
}

代码示例来源:origin: huxq17/tractor

@Override public void close() throws IOException {
  if (closed) return;
  if (bytesRemaining != 0
    && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   unexpectedEndOfInput();
  }
  closed = true;
 }
}

代码示例来源:origin: huxq17/SwipeCardsView

@Override public void close() throws IOException {
  if (closed) return;
  if (bytesRemaining != 0
    && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   unexpectedEndOfInput();
  }
  closed = true;
 }
}

代码示例来源:origin: apache/servicemix-bundles

@Override public void close() throws IOException {
  if (closed) return;
  if (bytesRemaining != 0 && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false, null);
  }
  closed = true;
 }
}

代码示例来源:origin: com.github.ljun20160606/okhttp

@Override public void close() throws IOException {
  if (closed) return;
  if (hasMoreChunks && !Util.discard(this, DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   endOfInput(false, null);
  }
  closed = true;
 }
}

代码示例来源:origin: huxq17/SwipeCardsView

@Override public void close() throws IOException {
  if (!cacheRequestClosed
    && !discard(this, HttpStream.DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   cacheRequestClosed = true;
   cacheRequest.abort();
  }
  source.close();
 }
};

代码示例来源:origin: huxq17/tractor

@Override public void close() throws IOException {
  if (!cacheRequestClosed
    && !discard(this, HttpStream.DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   cacheRequestClosed = true;
   cacheRequest.abort();
  }
  source.close();
 }
};

代码示例来源:origin: apache/servicemix-bundles

@Override public void close() throws IOException {
  if (!cacheRequestClosed
    && !discard(this, HttpCodec.DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   cacheRequestClosed = true;
   cacheRequest.abort();
  }
  source.close();
 }
};

代码示例来源:origin: duzechao/OKHttpUtils

@Override public void close() throws IOException {
  if (!cacheRequestClosed
    && !discard(this, HttpStream.DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   cacheRequestClosed = true;
   cacheRequest.abort();
  }
  source.close();
 }
};

代码示例来源:origin: com.github.ljun20160606/okhttp

@Override public void close() throws IOException {
  if (!cacheRequestClosed
    && !discard(this, HttpCodec.DISCARD_STREAM_TIMEOUT_MILLIS, MILLISECONDS)) {
   cacheRequestClosed = true;
   cacheRequest.abort();
  }
  source.close();
 }
};

相关文章