Skip to content

Commit e127f66

Browse files
Use ISO-8859-1 encoding instead of UTF-8 to Base64-encode the header value for Basic Authentication (same behavior as the Java generator).
1 parent aed8268 commit e127f66

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,19 @@ public string get_ProxyHost()
484484
{
485485
return _proxyHost;
486486
}
487+
#if NETCORE
488+
private static Encoding ISO_8859_1 = Encoding.Latin1;
489+
#else
490+
private static Encoding ISO_8859_1 = Encoding.GetEncoding("ISO-8859-1");
491+
#endif
492+
private const string AuthenticationSchemeBasic = "Basic";
487493
public void AddAuthentication(int scheme, string realm, string user, string password)
488494
{
489495
if (scheme >= _Basic && scheme <= _Kerberos)
490496
_authCollection.Add(new GxAuthScheme(scheme, realm, user, password));
491497
if (scheme == _Basic) {
492-
string authHeader = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{user}:{password}"));
493-
AddHeader(HttpHeader.AUTHORIZATION, new AuthenticationHeaderValue("Basic", authHeader).ToString());
498+
string authHeader = Convert.ToBase64String(ISO_8859_1.GetBytes($"{user}:{password}"));
499+
AddHeader(HttpHeader.AUTHORIZATION, new AuthenticationHeaderValue(AuthenticationSchemeBasic, authHeader).ToString());
494500
}
495501
}
496502

@@ -1036,7 +1042,7 @@ async Task ReadResponseDataAsync()
10361042
}
10371043
}
10381044
}
1039-
#endif
1045+
#endif
10401046
bool UseOldHttpClient(string name)
10411047
{
10421048
if (Config.GetValueOf("useoldhttpclient", out string useOld) && useOld.StartsWith("y", StringComparison.OrdinalIgnoreCase))

0 commit comments

Comments
 (0)