Skip to content

Commit 9797369

Browse files
committed
Exposed disable automatic proxy detection
1 parent 494055d commit 9797369

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

src/Elasticsearch.Net/Connection/Configuration/ConnectionConfiguration.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public class ConnectionConfiguration<T> : IConnectionConfigurationValues, IHideO
8888
#endif
8989
bool IConnectionConfigurationValues.MetricsEnabled { get{ return _enableMetrics; } }
9090

91-
private bool _automaticProxyDetection = true;
92-
bool IConnectionConfigurationValues.AutomaticProxyDetection { get { return _automaticProxyDetection; } }
91+
private bool _disableAutomaticProxyDetection = true;
92+
bool IConnectionConfigurationValues.DisableAutomaticProxyDetection { get { return _disableAutomaticProxyDetection; } }
9393

9494
private int _maximumAsyncConnections;
9595
int IConnectionConfigurationValues.MaximumAsyncConnections { get{ return _maximumAsyncConnections; } }
@@ -181,6 +181,11 @@ public T EnableTrace(bool enabled = true)
181181
return (T) this;
182182
}
183183

184+
public T DisableAutomaticProxyDetection(bool disable = true)
185+
{
186+
this._disableAutomaticProxyDetection = disable;
187+
return (T)this;
188+
}
184189

185190
/// <summary>
186191
/// By enabling metrics more metadata is returned per API call about requests (ping, sniff, failover) and general stats

src/Elasticsearch.Net/Connection/Configuration/IConnectionConfigurationValues.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface IConnectionConfigurationValues
2626
bool MetricsEnabled { get; }
2727
bool UsesPrettyResponses { get; }
2828
bool KeepRawResponse { get; }
29-
bool AutomaticProxyDetection { get; }
29+
bool DisableAutomaticProxyDetection { get; }
3030

3131
/// <summary>
3232
/// Instead of following a c/go like error checking on response.IsValid always throw an ElasticsearchServerException

src/Elasticsearch.Net/Connection/HttpConnection.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ private void SetProxyIfNeeded(HttpWebRequest myReq)
157157
proxy.Credentials = credentials;
158158
myReq.Proxy = proxy;
159159
}
160-
if(!this.ConnectionSettings.AutomaticProxyDetection)
160+
161+
if(this.ConnectionSettings.DisableAutomaticProxyDetection)
161162
{
162163
myReq.Proxy = null;
163164
}

src/Elasticsearch.Net/Connection/Transport.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private bool Ping(ITransportRequestState requestState)
8282
rq.Finish(response.Success, response.HttpStatusCode);
8383
}
8484
if (!response.HttpStatusCode.HasValue || response.HttpStatusCode.Value == -1)
85-
throw new Exception("ping returned no status code");
85+
throw new Exception("ping returned no status code", response.OriginalException);
8686
if (response.Response == null)
8787
return response.Success;
8888

src/Tests/Nest.Tests.Integration/Exceptions/ElasticsearchExceptionTests.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ public void ConnectionPool_SingleNode_PingExceptionThrowsMaxRetry()
121121
{
122122
var result = client.Search<ElasticsearchProject>(s => s.MatchAll());
123123
result.IsValid.Should().BeFalse();
124-
client.RootNodeInfo(r => r.RequestConfiguration(c => c.ConnectTimeout(2000)));
125124
});
126125
e.Should().NotBeNull();
127126
Assert.Pass(e.ToString());
@@ -140,7 +139,9 @@ public void ConnectionPool_SingleNode_PingExceptionThrowsMaxRetry_Async()
140139
);
141140
var e = Assert.Throws<MaxRetryException>(async () =>
142141
{
143-
var result = await client.SearchAsync<ElasticsearchProject>(s => s.MatchAll());
142+
var result = await client.SearchAsync<ElasticsearchProject>(s => s
143+
.MatchAll()
144+
);
144145
result.IsValid.Should().BeFalse();
145146
});
146147
e.Should().NotBeNull();

0 commit comments

Comments
 (0)