Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

fiddler抓不到请求

使用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();
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...