zoukankan      html  css  js  c++  java
  • 通过Fiddler抓取Java HttpClient的HTTP包

    设置HttpClient访问Fiddler的代理即可。

    public static void main(String[] args) throws Exception {
            
            HttpPost httpPost = new HttpPost("xxx");
            
            HttpHost proxy = new HttpHost("127.0.0.1",8888);
            RequestConfig requestConfig = RequestConfig.custom().setProxy(proxy).build();
            CloseableHttpClient httpclient= HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build();
            
            HttpResponse httpResponse = httpclient.execute(httpPost);
            int statusCode = httpResponse.getStatusLine().getStatusCode();
    
            System.out.println(httpResponse.getStatusLine());
    
            String result = null;
    
            if (statusCode == HttpStatus.SC_OK) {
                HttpEntity resEntity = httpResponse.getEntity();
                result = EntityUtils.toString(resEntity);
            }
    
            httpclient.getConnectionManager().shutdown();
            
            System.out.println("result:"+result);
        }
  • 相关阅读:
    linux
    ansible
    语法糖
    jupyter login
    hadoop patch
    ganglia
    unixbench安装使用
    linux使用FIO测试磁盘的iops
    cpu事实负载使用top命令
    phoronix-test-suite测试云服务器
  • 原文地址:https://www.cnblogs.com/yshyee/p/7819502.html
Copyright © 2011-2022 走看看