Skip to content

Commit

Permalink
Merge pull request restsharp#219 from Haacked/stringcomparisonfix
Browse files Browse the repository at this point in the history
Changed string comparisons to use `OrdinalIgnoreCase`
  • Loading branch information
johnsheehan committed Feb 13, 2012
2 parents db44f42 + b717259 commit 6b1e216
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RestSharp/Authenticators/HttpBasicAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void Authenticate(IRestClient client, IRestRequest request) {
// request.Credentials = new NetworkCredential(_username, _password);

// 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.InvariantCultureIgnoreCase)))
if (!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
{
var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", _username, _password)));
var authHeader = string.Format("Basic {0}", token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static bool IsNullOrBlank(this string value)

public static bool EqualsIgnoreCase(this string left, string right)
{
return String.Compare(left, right, StringComparison.InvariantCultureIgnoreCase) == 0;
return String.Compare(left, right, StringComparison.OrdinalIgnoreCase) == 0;
}

public static bool EqualsAny(this string input, params string[] args)
Expand Down
2 changes: 1 addition & 1 deletion RestSharp/Authenticators/OAuth2Authenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public OAuth2AuthorizationRequestHeaderAuthenticator(string accessToken)
public override void Authenticate(IRestClient client, IRestRequest request)
{
// only add the Authorization parameter if it hasn't been added.
if (!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.InvariantCultureIgnoreCase)))
if (!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
{
request.AddParameter("Authorization", _authorizationValue, ParameterType.HttpHeader);
}
Expand Down
2 changes: 1 addition & 1 deletion RestSharp/Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ private static void ExtractResponseData(HttpResponse response, HttpWebResponse w
response.ContentType = webResponse.ContentType;
response.ContentLength = webResponse.ContentLength;
#if WINDOWS_PHONE
if (string.Equals(webResponse.Headers[HttpRequestHeader.ContentEncoding], "gzip", StringComparison.InvariantCultureIgnoreCase))
if (string.Equals(webResponse.Headers[HttpRequestHeader.ContentEncoding], "gzip", StringComparison.OrdinalIgnoreCase))
response.RawBytes = new GZipStream(webResponse.GetResponseStream()).ReadAsBytes();
else
response.RawBytes = webResponse.GetResponseStream().ReadAsBytes();
Expand Down

0 comments on commit 6b1e216

Please sign in to comment.