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

Commit

Permalink
Replace p.Name.Equals with String.Equals. Fixes #23.
Browse files Browse the repository at this point in the history
  • Loading branch information
fubar-coder committed May 5, 2015
1 parent ec1dbb0 commit 4e5be0a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ This is some kind of a RestSharp port to PCL.

# Changes #

## 2.4.3 ##

* Bugfix for issue [#23](https://github.com/FubarDevelopment/restsharp.portable/issues/23).
Thanks to [GeirGrusom](https://github.com/GeirGrusom)

## 2.4.2 ##

* Bugfix for issue [#25](https://github.com/FubarDevelopment/restsharp.portable/issues/25).
Expand Down
14 changes: 14 additions & 0 deletions RestSharp.Portable.Test/IssueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Net.Http;
using System.Threading.Tasks;

using RestSharp.Portable.Authenticators;

using Xunit;

namespace RestSharp.Portable.Test
Expand Down Expand Up @@ -91,6 +93,18 @@ public void TestIssue19()
}
}

[Fact(DisplayName = "Issue 23")]
public async Task TestIssue23()
{
using (var client = new RestClient("http://httpbin.org/"))
{
client.Authenticator = new HttpBasicAuthenticator("foo", "bar");
var request = new RestRequest("post", HttpMethod.Get);
request.AddJsonBody("foo");
await client.Execute(request);
}
}

[Fact(DisplayName = "Issue 25")]
public void TestIssue25()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public HttpBasicAuthenticator(string username, string password)
public void Authenticate(IRestClient client, IRestRequest request)
{
// only add the Authorization parameter if it hasn't been added by a previous Execute
if (request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
if (request.Parameters.Any(p => p.Type == ParameterType.HttpHeader && string.Equals(p.Name, "Authorization", StringComparison.OrdinalIgnoreCase)))
return;
request.AddParameter("Authorization", _authHeader, ParameterType.HttpHeader);
}
Expand Down

0 comments on commit 4e5be0a

Please sign in to comment.