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

feature/traccar-sync
Mohamed Rashd 3 years ago
parent 37e598774e
commit 866686c6ea

@ -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);
}

Loading…
Cancel
Save