/// <summary> /// Remove the authorization HTTP header if it's not equal to the old one. /// </summary> /// <param name="parameters">List of HTTP headers</param> /// <param name="header">The type of the HTTP header that stores the authorization information</param> /// <param name="authValue">The authorization header value</param> /// <returns>true = header removed, false = same header already exists, null = header not found</returns> public static bool?RemoveAuthorizationHeader([NotNull, ItemNotNull] IParameterCollection parameters, AuthHeader header, [NotNull] string authValue) { var authParam = parameters.Find(ParameterType.HttpHeader, header.ToAuthorizationHeaderName()).FirstOrDefault(); if (authParam == null) { return(null); } var v = (string)authParam.Value; if (v != null && v == authValue) { return(false); } parameters.Remove(authParam); return(true); }