java 中网络发送的请求超时如何设置?
ConnManagerParams.setTimeout(params, 1000);
我查到的这个方法已经被废弃了,我的代码
headers.add(new BasicHeader("User-Agent", "Mozilla/5.0(Windows NT 6.1;Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0"));
headers.add(new BasicHeader("Referer", "https://gongshang.mingluji.com/beijing/"));
HttpClientBuilder httpClient = HttpClientBuilder.create().setDefaultHeaders(headers);
HttpGet httpGet = new HttpGet(url);
CloseableHttpResponse response = httpClient.build().execute(httpGet);
TimeUnit.SECONDS.sleep(SleepTime);
HttpEntity httpEntity = response.getEntity();
ResponseBody = EntityUtils.toString(httpEntity, "utf-8");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…