HttpHost proxy = new HttpHost("localhost",8888,"http");
RequestConfig config = RequestConfig.custom().setProxy(proxy).setConnectTimeout(10000).setSocketTimeout(15000).build();
CloseableHttpClient client= HttpClientBuilder.create().setDefaultRequestConfig(config).build();
HttpPost httpPost = new HttpPost("http://localhost:9999/anti_fraud/es/ga-es/capitalFrozen/sendData");
httpPost.setHeader("extra", "****");
MultipartEntityBuilder EntityBuilder = MultipartEntityBuilder.create();
ContentType contentType=ContentType.create("text/plain",Charset.forName("UTF-8"));
EntityBuilder.setCharset(Consts.UTF_8);
EntityBuilder.setContentType(ContentType.MULTIPART_FORM_DATA);
EntityBuilder.addPart("jsonStr", new StringBody(data,contentType));
httpPost.setEntity(EntityBuilder.build());
HttpResponse response = client.execute(httpPost);
相关文章
- 02-15Fiddler设置代理 抓取HttpClient请求参数
- 02-15Java:HttpClient篇,HttpClient4.2在Java中的几则应用:Get、Post参数、Session(会话)保持、Proxy(代理服务器)设置,多线程设置...
- 02-15接口测试——HttpClient工具的https请求、代理设置、请求头设置、获取状态码和响应头
- 02-15Fiddler-给手机设置代理并抓取https链接
- 02-15JMeter -----设置代理抓取web的HTTPS请求,“您的连接不是私密链接”的处理方案
- 02-15fiddler设置只抓取某一域名请求
- 02-15【手记】让Fiddler抓取入站请求,或者叫用Fiddler做反向代理
- 02-15Python爬虫:scrapy-splash的请求头和代理参数设置