diff --git a/sentry-core/src/main/java/io/sentry/core/AsyncConnectionFactory.java b/sentry-core/src/main/java/io/sentry/core/AsyncConnectionFactory.java index 061b4ad7c..2b0847b0a 100644 --- a/sentry-core/src/main/java/io/sentry/core/AsyncConnectionFactory.java +++ b/sentry-core/src/main/java/io/sentry/core/AsyncConnectionFactory.java @@ -14,7 +14,7 @@ public static AsyncConnection create(SentryOptions options) { // TODO: Take configuration values from SentryOptions HttpTransport transport = - new HttpTransport(options, null, setCredentials, 5000, 5000, false, sentryUrl); + new HttpTransport(options, setCredentials, 5000, 5000, false, sentryUrl); // TODO this should be made configurable at least for the Android case where we can // just not attempt to send if the device is offline. diff --git a/sentry-core/src/main/java/io/sentry/core/SentryOptions.java b/sentry-core/src/main/java/io/sentry/core/SentryOptions.java index 192e55f88..e705e9257 100644 --- a/sentry-core/src/main/java/io/sentry/core/SentryOptions.java +++ b/sentry-core/src/main/java/io/sentry/core/SentryOptions.java @@ -1,6 +1,7 @@ package io.sentry.core; import io.sentry.core.util.NonNull; +import java.net.Proxy; import java.util.ArrayList; import java.util.List; @@ -21,6 +22,7 @@ public class SentryOptions { private BeforeSendCallback beforeSend; private BeforeBreadcrumbCallback beforeBreadcrumb; private String cacheDirPath; + private Proxy proxy; public void addEventProcessor(EventProcessor eventProcessor) { eventProcessors.add(eventProcessor); @@ -129,6 +131,14 @@ public void setCacheDirPath(String cacheDirPath) { this.cacheDirPath = cacheDirPath; } + public Proxy getProxy() { + return proxy; + } + + public void setProxy(Proxy proxy) { + this.proxy = proxy; + } + public interface BeforeSendCallback { SentryEvent execute(SentryEvent event); } diff --git a/sentry-core/src/main/java/io/sentry/core/transport/HttpTransport.java b/sentry-core/src/main/java/io/sentry/core/transport/HttpTransport.java index 032cf0fec..6bc4806bf 100644 --- a/sentry-core/src/main/java/io/sentry/core/transport/HttpTransport.java +++ b/sentry-core/src/main/java/io/sentry/core/transport/HttpTransport.java @@ -37,7 +37,6 @@ public class HttpTransport implements ITransport { * obtained from the options. * * @param options sentry options to read the config from - * @param proxy the proxy to use, if any * @param connectionConfigurator this consumer is given a chance to set up the request before it * is sent * @param connectionTimeoutMills connection timeout in milliseconds @@ -46,13 +45,12 @@ public class HttpTransport implements ITransport { */ public HttpTransport( SentryOptions options, - @Nullable Proxy proxy, IConnectionConfigurator connectionConfigurator, int connectionTimeoutMills, int readTimeoutMills, boolean bypassSecurity, URL sentryUrl) { - this.proxy = proxy; + this.proxy = options.getProxy(); this.connectionConfigurator = connectionConfigurator; this.serializer = options.getSerializer(); this.connectionTimeout = connectionTimeoutMills; diff --git a/sentry-core/src/test/java/io/sentry/core/transport/HttpTransportTest.kt b/sentry-core/src/test/java/io/sentry/core/transport/HttpTransportTest.kt index bf7b1324c..440b6031e 100644 --- a/sentry-core/src/test/java/io/sentry/core/transport/HttpTransportTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/transport/HttpTransportTest.kt @@ -38,8 +38,9 @@ class HttpTransportTest { fun getSUT(): HttpTransport { val options = SentryOptions() options.serializer = serializer + options.proxy = proxy - return object : HttpTransport(options, proxy, requestUpdater, connectionTimeout, readTimeout, bypassSecurity, dsn) { + return object : HttpTransport(options, requestUpdater, connectionTimeout, readTimeout, bypassSecurity, dsn) { override fun open(url: URL?, proxy: Proxy?): HttpURLConnection { return connection }