使用Spring restTemplate.exchange时如何设置HTTP协议版本?

时间:2020-01-18 22:32:40

标签: java spring spring-boot spring-mvc

我正在使用Spring Framework restTemplate.exchange 方法执行 HTTPS GET 调用,并将响应对象映射到实体类,如下所示。 仅当我使用HTTP协议版本1.1( HTTP1.1 )发送请求时,目标服务器才会给出成功响应。我使用curl命令验证了它。 RestTemplate默认使用HTTP1.2。我在这里使用Apache HTTP Client v4.3,其中不推荐使用 httpClient.getParams 。因此,我无法使用getParams方法设置HTTP协议版本。使用restTemplate.exchange方法时,还有其他方法可以将http协议版本设置为 HTTP1.1 吗?

AndroidViewModel

0 个答案:

没有答案