diff --git a/csharp/autogen/src/HTTP.cs b/csharp/autogen/src/HTTP.cs index 0e8d372..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; @@ -570,19 +572,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=": @@ -590,10 +592,11 @@ 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 += $", qop={qop}"; //unquoted; see RFC7616-3.4 + authenticationFieldReply += string.Format(", qop={0}", qop); //unquoted; see RFC7616-3.4 } break; } @@ -601,11 +604,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 +646,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);