From e46afc4624ea65a26f4556fe6d6505f899c4e9f4 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Tue, 1 Dec 2020 15:15:34 +0000 Subject: [PATCH 1/2] Reverted string interpolation to string.Format() Signed-off-by: Konstantina Chremmou --- csharp/autogen/src/HTTP.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/csharp/autogen/src/HTTP.cs b/csharp/autogen/src/HTTP.cs index 0e8d372..ae7ca26 100644 --- a/csharp/autogen/src/HTTP.cs +++ b/csharp/autogen/src/HTTP.cs @@ -570,19 +570,19 @@ private static void AuthenticateProxy(ref Stream stream, Uri uri, IWebProxy prox throw new ProxyServerAuthenticationException("Stale nonce in Digest authentication attempt."); break; case "realm=": - authenticationFieldReply += $", realm=\"{directives[++i]}\""; + authenticationFieldReply += string.Format(", realm=\"{0}\"", directives[++i]); realm = directives[i]; break; case "nonce=": - authenticationFieldReply += $", nonce=\"{directives[++i]}\""; + authenticationFieldReply += string.Format(", nonce=\"{0}\"", directives[++i]); nonce = directives[i]; break; case "opaque=": - authenticationFieldReply += $", opaque=\"{directives[++i]}\""; + authenticationFieldReply += string.Format(", opaque=\"{0}\"", directives[++i]); opaque = directives[i]; break; case "algorithm=": - authenticationFieldReply += $", algorithm={directives[++i]}"; //unquoted; see RFC7616-3.4 + authenticationFieldReply += string.Format(", algorithm={0}", directives[++i]); //unquoted; see RFC7616-3.4 algorithm = directives[i]; break; case "qop=": @@ -593,7 +593,7 @@ private static void AuthenticateProxy(ref Stream stream, Uri uri, IWebProxy prox qops.FirstOrDefault(q => q.ToLowerInvariant() == "auth-int") ?? throw new ProxyServerAuthenticationException( "Digest authentication's quality-of-protection directive is not supported."); - authenticationFieldReply += $", qop={qop}"; //unquoted; see RFC7616-3.4 + authenticationFieldReply += string.Format(", qop={0}", qop); //unquoted; see RFC7616-3.4 } break; } @@ -601,11 +601,11 @@ private static void AuthenticateProxy(ref Stream stream, Uri uri, IWebProxy prox string clientNonce = GenerateNonce(); if (qop != null) - authenticationFieldReply += $", cnonce=\"{clientNonce}\""; + authenticationFieldReply += string.Format(", cnonce=\"{0}\"", clientNonce); string nonceCount = "00000001"; // todo: track nonces and their corresponding nonce counts if (qop != null) - authenticationFieldReply += $", nc={nonceCount}"; //unquoted; see RFC7616-3.4 + authenticationFieldReply += string.Format(", nc={0}", nonceCount); //unquoted; see RFC7616-3.4 Func algFunc; var scratch1 = string.Join(":", credentials.UserName, realm, credentials.Password); @@ -643,7 +643,7 @@ private static void AuthenticateProxy(ref Stream stream, Uri uri, IWebProxy prox : new[] {HA1, nonce, nonceCount, clientNonce, qop, HA2}; var response = algFunc(string.Join(":", array3)); - authenticationFieldReply += $", response=\"{response}\""; + authenticationFieldReply += string.Format(", response=\"{0}\"", response); WriteLine(header, stream); WriteLine(authenticationFieldReply, stream); From afdd02b3b291a67585354782938e4c554b7dfe5c Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Tue, 1 Dec 2020 23:10:28 +0000 Subject: [PATCH 2/2] Reverted two more C# 6.0 features. Signed-off-by: Konstantina Chremmou --- csharp/autogen/src/HTTP.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/csharp/autogen/src/HTTP.cs b/csharp/autogen/src/HTTP.cs index ae7ca26..8f1412b 100644 --- a/csharp/autogen/src/HTTP.cs +++ b/csharp/autogen/src/HTTP.cs @@ -324,9 +324,11 @@ private static string ComputeHash(string input, string method) using (var hasher = HashAlgorithm.Create(method)) { - byte[] hash = hasher?.ComputeHash(bytes); - if (hash != null) + if (hasher != null) + { + byte[] hash = hasher.ComputeHash(bytes); return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); + } } return null; @@ -590,7 +592,8 @@ private static void AuthenticateProxy(ref Stream stream, Uri uri, IWebProxy prox if (qops.Length > 0) { qop = qops.FirstOrDefault(q => q.ToLowerInvariant() == "auth") ?? - qops.FirstOrDefault(q => q.ToLowerInvariant() == "auth-int") ?? + qops.FirstOrDefault(q => q.ToLowerInvariant() == "auth-int"); + if (qop == null) throw new ProxyServerAuthenticationException( "Digest authentication's quality-of-protection directive is not supported."); authenticationFieldReply += string.Format(", qop={0}", qop); //unquoted; see RFC7616-3.4