Skip to content

Commit

Permalink
Fix duplication of accept header
Browse files Browse the repository at this point in the history
  • Loading branch information
geminiKim committed Jan 29, 2019
1 parent cc4e069 commit a57fa66
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.lang.reflect.Type;
import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -767,7 +768,7 @@ public void doWithRequest(ClientHttpRequest request) throws IOException {
if (this.responseType instanceof Class) {
responseClass = (Class<?>) this.responseType;
}
List<MediaType> allSupportedMediaTypes = new ArrayList<MediaType>();
Set<MediaType> allSupportedMediaTypes = new LinkedHashSet<MediaType>();
for (HttpMessageConverter<?> converter : getMessageConverters()) {
if (responseClass != null) {
if (converter.canRead(responseClass, null)) {
Expand All @@ -782,11 +783,12 @@ else if (converter instanceof GenericHttpMessageConverter) {
}
}
if (!allSupportedMediaTypes.isEmpty()) {
MediaType.sortBySpecificity(allSupportedMediaTypes);
List<MediaType> result = new ArrayList<MediaType>(allSupportedMediaTypes);
MediaType.sortBySpecificity(result);
if (logger.isDebugEnabled()) {
logger.debug("Setting request Accept header to " + allSupportedMediaTypes);
}
request.getHeaders().setAccept(allSupportedMediaTypes);
request.getHeaders().setAccept(result);
}
}
}
Expand Down

0 comments on commit a57fa66

Please sign in to comment.