okhttp3.mockwebserver.MockWebServer.sleepIfDelayed()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(118)

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

MockWebServer.sleepIfDelayed介绍

暂无

代码示例

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

private void writeHttpResponse(Socket socket, BufferedSink sink, MockResponse response)
  throws IOException {
 sleepIfDelayed(response.getHeadersDelay(TimeUnit.MILLISECONDS));
 sink.writeUtf8(response.getStatus());
 sink.writeUtf8("\r\n");
 writeHeaders(sink, response.getHeaders());
 Buffer body = response.getBody();
 if (body == null) return;
 sleepIfDelayed(response.getBodyDelay(TimeUnit.MILLISECONDS));
 throttledTransfer(response, socket, body, sink, body.size(), false);
 if ("chunked".equalsIgnoreCase(response.getHeaders().get("Transfer-Encoding"))) {
  writeHeaders(sink, response.getTrailers());
 }
}

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

private void writeHttpResponse(Socket socket, BufferedSink sink, MockResponse response)
  throws IOException {
 sleepIfDelayed(response.getBodyDelay(TimeUnit.MILLISECONDS));
 sink.writeUtf8(response.getStatus());
 sink.writeUtf8("\r\n");
 Headers headers = response.getHeaders();
 for (int i = 0, size = headers.size(); i < size; i++) {
  sink.writeUtf8(headers.name(i));
  sink.writeUtf8(": ");
  sink.writeUtf8(headers.value(i));
  sink.writeUtf8("\r\n");
 }
 sink.writeUtf8("\r\n");
 sink.flush();
 Buffer body = response.getBody();
 if (body == null) return;
 sleepIfDelayed(response.getBodyDelay(TimeUnit.MILLISECONDS));
 throttledTransfer(response, socket, body, sink, body.size(), false);
}

相关文章