mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 14:09:25 +00:00
Support HttpComponents 5.6
This commit updates the HttpComponents HttpClient to refer to the parsed `HttpEntity` for the content-related HTTP response headers such as encoding and body length. Closes gh-36100
This commit is contained in:
+10
@@ -66,6 +66,16 @@ final class HttpComponentsClientHttpResponse implements ClientHttpResponse {
|
||||
public HttpHeaders getHeaders() {
|
||||
if (this.headers == null) {
|
||||
MultiValueMap<String, String> adapter = new HttpComponentsHeadersAdapter(this.httpResponse);
|
||||
// update headers if response is decompressed
|
||||
HttpEntity httpEntity = this.httpResponse.getEntity();
|
||||
if (httpEntity != null) {
|
||||
if (httpEntity.getContentLength() == -1) {
|
||||
adapter.remove(HttpHeaders.CONTENT_LENGTH);
|
||||
}
|
||||
if (httpEntity.getContentEncoding() == null) {
|
||||
adapter.remove(HttpHeaders.CONTENT_ENCODING);
|
||||
}
|
||||
}
|
||||
this.headers = HttpHeaders.readOnlyHttpHeaders(adapter);
|
||||
}
|
||||
return this.headers;
|
||||
|
||||
Reference in New Issue
Block a user