Skip to content

Commit

Permalink
Rollback change with proxyHost and proxyPort and switched to using We…
Browse files Browse the repository at this point in the history
…bRequest.DefaultWebProxy instead
  • Loading branch information
ThomasArdal committed Nov 1, 2024
1 parent e7db144 commit 3eaba79
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 55 deletions.
13 changes: 0 additions & 13 deletions src/Elmah.Io/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,5 @@ internal static string ApplicationName(this IDictionary dictionary)
const string applicationname = "applicationName";
return dictionary.ContainsCaseInsensitive(applicationname) ? dictionary.ValueByKeyCaseInsensitive(applicationname) : string.Empty;
}

internal static string ProxyHost(this IDictionary dictionary)
{
const string proxyHost = "proxyHost";
return dictionary.ContainsCaseInsensitive(proxyHost) ? dictionary.ValueByKeyCaseInsensitive(proxyHost) : string.Empty;
}

internal static int? ProxyPort(this IDictionary dictionary)
{
const string proxyPort = "proxyPort";
var value = dictionary.ContainsCaseInsensitive(proxyPort) ? dictionary.ValueByKeyCaseInsensitive(proxyPort) : null;
return !string.IsNullOrWhiteSpace(value) && int.TryParse(value, out var port) ? port : null;
}
}
}
14 changes: 3 additions & 11 deletions src/Elmah.Io/ErrorLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,12 @@ public ErrorLog(IDictionary config)

if (Api != null) return;

var options = new ElmahIoOptions
var elmahioApi = ElmahioAPI.Create(apiKey, new ElmahIoOptions
{
Timeout = new TimeSpan(0, 0, 5),
UserAgent = UserAgent(),
};

var proxyHost = config.ProxyHost();
var proxyPort = config.ProxyPort();
if (proxyHost != null && proxyPort != null)
{
options.WebProxy = new WebProxy(proxyHost, (int)proxyPort);
}

var elmahioApi = ElmahioAPI.Create(apiKey, options);
WebProxy = WebRequest.DefaultWebProxy,
});

Api = elmahioApi;
}
Expand Down
31 changes: 0 additions & 31 deletions test/Elmah.Io.Tests/DictionaryExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,6 @@ public void CanGetApplicationName(string expectedValue, string key, string value
Assert.That(dictionary.ApplicationName(), Is.EqualTo(expectedValue));
}

[TestCase(null, "proxyHost", null)]
[TestCase("", "proxyHost", "")]
[TestCase("value", "proxyHost", "value")]
[TestCase("value", "proxyHost", "value")]
[TestCase("", null, null)]
public void CanGetProxyHost(string expectedValue, string key, string value)
{
var dictionary = new Hashtable();
if (!string.IsNullOrWhiteSpace(key))
{
dictionary.Add(key, value);
}

Assert.That(dictionary.ProxyHost(), Is.EqualTo(expectedValue));
}

[TestCase(null, "proxyPort", null)]
[TestCase(null, "proxyPort", "")]
[TestCase(5555, "proxyPort", "5555")]
[TestCase(6666, "proxyPort", "6666")]
public void CanGetProxyPort(int? expectedValue, string key, string value)
{
var dictionary = new Hashtable();
if (!string.IsNullOrWhiteSpace(key))
{
dictionary.Add(key, value);
}

Assert.That(dictionary.ProxyPort(), Is.EqualTo(expectedValue));
}

[TestCase(false, "DC14639C-B930-4960-9A3A-BD73C6CA6375", "logId", "DC14639C-B930-4960-9A3A-BD73C6CA6375")]
[TestCase(false, "E70628F4-EEED-4C06-B570-663F8AFA80E5", "LogId", "E70628F4-EEED-4C06-B570-663F8AFA80E5")]
[TestCase(true, null, "logId", "No guid")]
Expand Down

0 comments on commit 3eaba79

Please sign in to comment.