Add option for HTTP client rule node to not create any message body, for example on a DELETE request where technically a body is allowed but the receiving server disallows any body content.

This commit is contained in:
Matt Magoffin 2021-09-30 18:11:17 +13:00
parent c52c9a16ed
commit ef90332998
2 changed files with 4 additions and 1 deletions

View File

@ -176,7 +176,8 @@ public class TbHttpClient {
HttpMethod method = HttpMethod.valueOf(config.getRequestMethod()); HttpMethod method = HttpMethod.valueOf(config.getRequestMethod());
HttpEntity<String> entity; HttpEntity<String> entity;
if(HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method) || if(HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method) ||
HttpMethod.OPTIONS.equals(method) || HttpMethod.TRACE.equals(method)) { HttpMethod.OPTIONS.equals(method) || HttpMethod.TRACE.equals(method) ||
config.isIgnoreRequestBody()) {
entity = new HttpEntity<>(headers); entity = new HttpEntity<>(headers);
} else { } else {
entity = new HttpEntity<>(msg.getData(), headers); entity = new HttpEntity<>(msg.getData(), headers);

View File

@ -47,6 +47,7 @@ public class TbRestApiCallNodeConfiguration implements NodeConfiguration<TbRestA
private String proxyPassword; private String proxyPassword;
private String proxyScheme; private String proxyScheme;
private ClientCredentials credentials; private ClientCredentials credentials;
private boolean ignoreRequestBody;
@Override @Override
public TbRestApiCallNodeConfiguration defaultConfiguration() { public TbRestApiCallNodeConfiguration defaultConfiguration() {
@ -61,6 +62,7 @@ public class TbRestApiCallNodeConfiguration implements NodeConfiguration<TbRestA
configuration.setTrimQueue(false); configuration.setTrimQueue(false);
configuration.setEnableProxy(false); configuration.setEnableProxy(false);
configuration.setCredentials(new AnonymousCredentials()); configuration.setCredentials(new AnonymousCredentials());
configuration.setIgnoreRequestBody(false);
return configuration; return configuration;
} }