From 866686c6ead6abd3e0a742d834d4bcbb092f0127 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Tue, 22 Feb 2022 16:50:51 +0530 Subject: [PATCH] Fix post api failing when trying the with refresh token due to non repeatable http entity --- .../io/entgra/ui/request/interceptor/util/HandlerUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java index 64f8a3e221f..ece5d92d9b6 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java @@ -39,6 +39,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.cookie.SM; +import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.InputStreamEntity; import org.apache.http.entity.StringEntity; @@ -413,14 +414,14 @@ public class HandlerUtil { entityBuilder.addTextBody(item.getFieldName(), item.getString()); } } - proxyRequest.setEntity(entityBuilder.build()); + proxyRequest.setEntity(new BufferedHttpEntity(entityBuilder.build())); HandlerUtil.copyRequestHeaders(req, proxyRequest, false); } else { if (StringUtils.isNotEmpty(req.getHeader(HttpHeaders.CONTENT_LENGTH)) || StringUtils.isNotEmpty(req.getHeader(HttpHeaders.TRANSFER_ENCODING))) { InputStreamEntity entity = new InputStreamEntity(req.getInputStream(), Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH))); - proxyRequest.setEntity(entity); + proxyRequest.setEntity(new BufferedHttpEntity(entity)); } HandlerUtil.copyRequestHeaders(req, proxyRequest, true); }