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

x33g5p2x  于2022-01-19 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(188)

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

HttpClient.setTimeout介绍

[英]Sets the socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout.
[中]以毫秒为单位设置套接字超时(SO_timeout),这是等待数据的超时。超时值为零被解释为无限超时。

代码示例

代码示例来源:origin: tracee/tracee

@Override
@SuppressWarnings("deprecation")
public synchronized void setTimeout(int newTimeoutInMilliseconds) {
  delegate.setTimeout(newTimeoutInMilliseconds);
}

代码示例来源:origin: approvals/ApprovalTests.Java

/***********************************************************************/
public InputStream getResponse(HttpClient client, PostMethod post) throws HttpException, IOException
{
 //    My_System.markerIn();
 //    My_System.variable(post.getURI().toString());
 //    My_System.variable("parameters", post.getParameters());
 client.setConnectionTimeout(30000);
 client.setTimeout(30000);
 client.executeMethod(post);
 InputStream r = post.getResponseBodyAsStream();
 //    My_System.markerOut();
 return r;
}
/***********************************************************************/

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

private GetMethod doGet(URL url, int timeout) throws IOException {
  HttpClient client = getClient();
  client.setTimeout(timeout);
  GetMethod get = new GetMethod(normalizeToString(url));
  get.setDoAuthentication(useAuthentication(url) || useProxyAuthentication());
  get.setRequestHeader("Accept-Encoding", "gzip,deflate");
  client.executeMethod(get);
  return get;
}

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

private HeadMethod doHead(URL url, int timeout) throws IOException {
  HttpClient client = getClient();
  client.setTimeout(timeout);
  HeadMethod head = new HeadMethod(normalizeToString(url));
  head.setDoAuthentication(useAuthentication(url) || useProxyAuthentication());
  client.executeMethod(head);
  return head;
}

相关文章