zoukankan      html  css  js  c++  java
  • HttpClient不同版本超时时间的设置

    引自 https://www.cnblogs.com/hisunhyx/p/5028391.html

    3.X是这样的

    HttpClient client=new DefaultHttpClient();
    client.setConnectionTimeout(30000); 
    client.setTimeout(30000);
    4.X是这样的
    HttpClient httpClient=new DefaultHttpClient();
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,2000);//连接时间
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,2000);//数据传输时间
    4.3是这样的
    CloseableHttpClient httpClient = HttpClients.createDefault();
    HttpGet httpGet=new HttpGet("http://www.baidu.com");//HTTP Get请求(POST雷同)
    RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(2000).setConnectTimeout(2000).build();//设置请求和传输超时时间
    httpGet.setConfig(requestConfig);
    httpClient.execute(httpGet);//执行请求
  • 相关阅读:
    go2基本类型
    go1
    android studio 使用
    ios34---GDC,dispatch_once
    ios33--线程通信
    ios33--线程安全
    ios32---线程的状态
    ios31--NSThread
    ios30---pthread, NSThread, GCD, NSOperation
    ios29--多线程
  • 原文地址:https://www.cnblogs.com/hutao722/p/7890853.html
Copyright © 2011-2022 走看看