使用fiddler抓vertx框架发送的请求却抓不到
但是使用new URL形式就可以。这是为什么呢
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "9999");
String url = "http://view.news.qq.com/original/intouchtoday/n3131.html";
Vertx vertx = Vertx.vertx();
HttpClient client = HttpClientUtils.getDefaultHttp(vertx);
client.postAbs(url, resHandler -> {
resHandler.bodyHandler(bodyHandler -> {
System.out.printf(bodyHandler.toString() + "11111111111111111111111111");
client.close();
return;
});
}).putHeader("content-length", "" + "a".getBytes().length).write("a")
.setTimeout(3000).exceptionHandler(ex -> {
System.out.println("time out----------------------------------------------------------");
client.close();
return;
}).end();
client.close();
vertx.close();
以下代码可以成功抓到
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "9999");
try {
URL url = new URL("http://view.news.qq.com/original/intouchtoday/n3131.html");
URLConnection connection = url.openConnection();
connection.getInputStream();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…