Skip to content

Commit

Permalink
fix: fix RouterLabelRestTemplateInterceptor add response headers exce…
Browse files Browse the repository at this point in the history
…ption with httpclient5 (#1337)
  • Loading branch information
fuyuwei01 authored Jul 15, 2024
1 parent 3a35bfc commit a6079fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
- [feat:upgrade jackson version.](https://github.com/Tencent/spring-cloud-tencent/pull/1259)
- [fix:fix ApplicationContextAwareUtils NPE bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1294)
- [feat:upgrade jacoco version.](https://github.com/Tencent/spring-cloud-tencent/pull/1308)
- [fix: fix RouterLabelRestTemplateInterceptor add response headers exception with httpclient5.](https://github.com/Tencent/spring-cloud-tencent/pull/1337)
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
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;
Expand Down Expand Up @@ -104,7 +105,8 @@ public ClientHttpResponse intercept(@NonNull HttpRequest request, @NonNull byte[
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)));
}

Expand Down

0 comments on commit a6079fc

Please sign in to comment.