Merge branch 'fix/post/api/not/non/repeatable/entity' into 'master'

Fix post api failing when trying the with refresh token due to non repeatable http entity

See merge request entgra/carbon-device-mgt!850
temp
Inosh Perara 3 years ago
commit 294bf8ae90

@ -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;
@ -422,14 +423,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);
}

Loading…
Cancel
Save