Apache HttpClient 4.5将POST请求重定向到GET请求

问题描述 投票:1回答:1

Am用托盘打到一个发布端点,但是它给出了错误302,当我在同一台服务器上尝试另一个get Url时,它给了我200。然后我使用LaxRedirectStrategy()重定向了发布请求,发布请求正在重定向至get请求(同一端点,仅方法名是GET和POST),它没有从post方法获取响应。谁能告诉我如何使用apahce httpClient 4.5将发布请求重定向到发布请求

HttpClient client= HttpClientBuilder.create()
 .setRedirectStrategy(new LaxRedirectStrategy()).build();
HttpPost post = new HttpPost("url");
post.addHeader("content-type", " application/json");
HttpResponse response = client.execute(post);
java spring-boot apache-httpclient-4.x
1个回答
0
投票

我遇到了同样的问题,我通过将LaxRedirectStrategy

© www.soinside.com 2019 - 2024. All rights reserved.