设置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);
    }

 

相关文章:

  • 2021-12-03
  • 2021-12-27
  • 2021-09-14
  • 2021-11-06
猜你喜欢
  • 2021-12-23
  • 2022-01-11
  • 2021-05-30
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案