Skip to content

Commit 02b6d54

Browse files
authored
Prefer config supplied content-type and accept header.
Original Pull Request #2328 Closes #2327
1 parent 8bb3474 commit 02b6d54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/org/springframework/data/elasticsearch/client/reactive/WebClientProvider.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,15 @@ static WebClientProvider getWebClientProvider(ClientConfiguration clientConfigur
256256
HttpHeaders suppliedHeaders = clientConfiguration.getHeadersSupplier().get();
257257

258258
if (suppliedHeaders != null && suppliedHeaders != HttpHeaders.EMPTY) {
259+
260+
// remove content-type and accept if they are provided by the client configuration (ES7 compatibility headers)
261+
if (suppliedHeaders.containsKey(HttpHeaders.CONTENT_TYPE)) {
262+
httpHeaders.remove(HttpHeaders.CONTENT_TYPE);
263+
}
264+
if (suppliedHeaders.containsKey(HttpHeaders.ACCEPT)) {
265+
httpHeaders.remove(HttpHeaders.ACCEPT);
266+
}
267+
259268
httpHeaders.addAll(suppliedHeaders);
260269
}
261270
}));

0 commit comments

Comments
 (0)