Resttemplate 表单提交获取文件,返回 302 , Transfer-Encoding:"chunked",获取到数据为 null

2021-10-03 14:53:39 +08:00
 ilovemo
https://www.poi86.com/poi/download_street_geojson/22054.html 这个页面资源,通过 Resttemplate 获取,Resttemplate 表单提交获取文件,返回 302,Transfer-Encoding:"chunked",获取到数据为 null,这是为啥啊,这是我核心代码:


//设置为 form 方式
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.set("Accept-Encoding","gzip, deflate, br");
headers.set("Content-Length","27");
headers.set("Connection","keep-alive");
//设置请求参数
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
parameters.add("streetid", adcode);
parameters.add("Captcha", captcha);//https://www.poi86.com/poi/download_street_geojson/25357.html
HttpEntity<MultiValueMap<String, String>> multiValueMapHttpEntity = new HttpEntity<>(parameters, headers);
ResponseEntity<byte[]> result = restTemplate.postForEntity(GEO_URL_PREFIX + "/GeoJson/Street", multiValueMapHttpEntity, byte[].class);

求解决方案,
708 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/805752

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX