简体   繁体   中英

Spring RestTemplate not returning all Headers

I am calling a service with postForEntity method, and I need data that is included in the header. When I check through Postman I can confirm that the service returns 4 headers ( "date", "content-type", "content-length", "link" ).

However after calling responseEntity = restTemplate.postForEntity(uri, request, responseType) the responseEntity only contains 3 headers ( "date", "content-type", "content-length")

Is there something about non-standard headers that doesn't work with postForEntity? And if so what is the fix?

For the record, I'm currently using SpringBoot version 1.5.6.RELEASE

I was able to get this working by adding another dependancy to my pom.xml

<dependency> <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        version>4.5.3</version>
</dependency>

No other changes to the code were made. It seems that the Spring framework by default only reads standard headers but adding this library gave it the functionality to read the "link" header that I wanted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM