I am calling some rest endpointusing rest template in spring boot as below:
ResponseEntity<String> responseEntity = restTemplate.exchange(url, httpMethod, entity, String.class);
And than i am reading all headers from response entity like below:
HttpHeaders httpHeaders = responseEntity.getHeaders();
But HttpHeaders contains so many headers, from from these i only want to read headers which are custom headers, and we do not know the custom header names, s obasically i just want to remove all standard HTTP headers and get all remaining headers.
How can we remove all standard HTTP headers?
CodePudding user response:
The Map class has a remove() method. You could iterate over a list of all known headers, removing each of them. What is left would be your custom headers.
Alternately you could use the toCommaDelimitedString method on HttpHeaders, and then iterate over that removing all known headers.
CodePudding user response:
class HttpHeaders defined All standard HTTP headers Key,so what you need to do is provide a method to filter out custom headers your expect