Skip to content

Commit

Permalink
feat(proxy): Proxy exception list for outbound http connectors (#3460) (
Browse files Browse the repository at this point in the history
#3471)

* feat(rest): Use System Properties for proxy configuration
  • Loading branch information
johnBgood authored Oct 8, 2024
1 parent 3dc822c commit 443fa79
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ void basicAuth() {
.property("authentication.type", BasicAuthentication.TYPE)
.property("authentication.username", "username")
.property("authentication.password", "password")
.property("body", "={\"order\": {\"status\": \"processing\", \"id\": string(42+3)}}")
.property("resultExpression", "={orderStatus: response.body.order.status}")
.writeTo(new File(tempDir, "template.json"));

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@
package io.camunda.connector.http.base.client.apache;

import io.camunda.connector.api.error.ConnectorException;
import io.camunda.connector.api.error.ConnectorExceptionBuilder;
import io.camunda.connector.http.base.client.HttpClient;
import io.camunda.connector.http.base.client.HttpStatusHelper;
import io.camunda.connector.http.base.client.ProxyConfiguration;
import io.camunda.connector.http.base.exception.ConnectorExceptionMapper;
import io.camunda.connector.http.base.model.HttpCommonRequest;
import io.camunda.connector.http.base.model.HttpCommonResult;
import java.io.IOException;
import java.net.URISyntaxException;
import org.apache.hc.client5.http.ClientProtocolException;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.io.SocketConfig;
import org.apache.hc.core5.util.Timeout;
Expand Down Expand Up @@ -104,7 +100,9 @@ public HttpCommonResult execute(HttpCommonRequest request, boolean remoteExecuti
var result =
httpClientBuilder
.setDefaultRequestConfig(getRequestConfig(request))
.setProxy(getProxyConfig())
// Will allow customers to use system properties for proxy configuration
// (http.proxyHost, http.proxyPort, etc)
.useSystemProperties()
.build()
.execute(apacheRequest, new HttpCommonResultResponseHandler(remoteExecutionEnabled));
if (HttpStatusHelper.isError(result.status())) {
Expand All @@ -124,24 +122,6 @@ public HttpCommonResult execute(HttpCommonRequest request, boolean remoteExecuti
}
}

HttpHost getProxyConfig() {
ProxyConfiguration proxyConfiguration = new ProxyConfiguration();
return proxyConfiguration
.getHttpProxyUrl()
.map(
s -> {
try {
return HttpHost.create(s);
} catch (URISyntaxException e) {
throw new ConnectorExceptionBuilder()
.message("Cannot create host from URL:" + s)
.cause(e)
.build();
}
})
.orElse(null);
}

private RequestConfig getRequestConfig(HttpCommonRequest request) {
return RequestConfig.custom()
.setConnectionRequestTimeout(Timeout.ofSeconds(request.getConnectionTimeoutInSeconds()))
Expand Down
Loading

0 comments on commit 443fa79

Please sign in to comment.