fix: fix RouterLabelRestTemplateInterceptor add response headers exception with httpclient5 (#1376)

Co-authored-by: Haotian Zhang <skyebefreeman@qq.com>
Co-authored-by: gzoldou <gzoldou@163.com>
pull/1377/head
Fishtail 4 months ago committed by GitHub
parent c7f4b76eeb
commit 54d04d80d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,3 +4,4 @@
- [feat:upgrade jackson version.](https://github.com/Tencent/spring-cloud-tencent/pull/1258)
- [fix:fix ApplicationContextAwareUtils NPE bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1296)
- [feat:upgrade jacoco version.](https://github.com/Tencent/spring-cloud-tencent/pull/1307)
- [fix: fix RouterLabelRestTemplateInterceptor add response headers exception with httpclient5.](https://github.com/Tencent/spring-cloud-tencent/pull/1376)

@ -44,6 +44,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
@ -103,7 +104,8 @@ public class RouterLabelRestTemplateInterceptor implements ClientHttpRequestInte
ClientHttpResponse response = clientHttpRequestExecution.execute(request, body);
if (!CollectionUtils.isEmpty(request.getHeaders().get(RouterConstant.ROUTER_LABEL_HEADER))) {
response.getHeaders().addAll(RouterConstant.ROUTER_LABEL_HEADER, Objects.requireNonNull(request.getHeaders()
HttpHeaders responseHeaders = HttpHeaders.writableHttpHeaders(response.getHeaders());
responseHeaders.addAll(RouterConstant.ROUTER_LABEL_HEADER, Objects.requireNonNull(request.getHeaders()
.get(RouterConstant.ROUTER_LABEL_HEADER)));
}

Loading…
Cancel
Save