Skip to content
This repository was archived by the owner on Apr 10, 2018. It is now read-only.

Commit 4e5be0a

Browse files
committed
Replace p.Name.Equals with String.Equals. Fixes #23.
1 parent ec1dbb0 commit 4e5be0a

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ This is some kind of a RestSharp port to PCL.
1010

1111
# Changes #
1212

13+
## 2.4.3 ##
14+
15+
* Bugfix for issue [#23](https://github.com/FubarDevelopment/restsharp.portable/issues/23).
16+
Thanks to [GeirGrusom](https://github.com/GeirGrusom)
17+
1318
## 2.4.2 ##
1419

1520
* Bugfix for issue [#25](https://github.com/FubarDevelopment/restsharp.portable/issues/25).

RestSharp.Portable.Test/IssueTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Net.Http;
55
using System.Threading.Tasks;
66

7+
using RestSharp.Portable.Authenticators;
8+
79
using Xunit;
810

911
namespace RestSharp.Portable.Test
@@ -91,6 +93,18 @@ public void TestIssue19()
9193
}
9294
}
9395

96+
[Fact(DisplayName = "Issue 23")]
97+
public async Task TestIssue23()
98+
{
99+
using (var client = new RestClient("http://httpbin.org/"))
100+
{
101+
client.Authenticator = new HttpBasicAuthenticator("foo", "bar");
102+
var request = new RestRequest("post", HttpMethod.Get);
103+
request.AddJsonBody("foo");
104+
await client.Execute(request);
105+
}
106+
}
107+
94108
[Fact(DisplayName = "Issue 25")]
95109
public void TestIssue25()
96110
{

RestSharp.Portable/Authenticators/HttpBasicAuthenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public HttpBasicAuthenticator(string username, string password)
3030
public void Authenticate(IRestClient client, IRestRequest request)
3131
{
3232
// only add the Authorization parameter if it hasn't been added by a previous Execute
33-
if (request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
33+
if (request.Parameters.Any(p => p.Type == ParameterType.HttpHeader && string.Equals(p.Name, "Authorization", StringComparison.OrdinalIgnoreCase)))
3434
return;
3535
request.AddParameter("Authorization", _authHeader, ParameterType.HttpHeader);
3636
}

0 commit comments

Comments
 (0)