Skip to content

Commit

Permalink
[feat]应用Http客户端自定义UserAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jun 23, 2024
1 parent be8ee54 commit 320b983
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion NewLife.Remoting/Clients/ClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public abstract class ClientBase : DisposeBase, ICommandClient, IEventProvider,

/// <summary>协议版本</summary>
private readonly static String _version;
private readonly static String _name;
private TimeSpan _span;
private readonly ConcurrentQueue<IPingRequest> _fails = new();
private readonly ICache _cache = new MemoryCache();
Expand All @@ -71,6 +72,7 @@ static ClientBase()
{
var asm = AssemblyX.Entry ?? AssemblyX.Create(Assembly.GetExecutingAssembly());
_version = asm?.FileVersion + "";
_name = asm?.Name ?? "NewLifeRemoting";
}

/// <summary>实例化</summary>
Expand Down Expand Up @@ -141,7 +143,7 @@ protected virtual void OnInit()
/// <summary>创建Http客户端</summary>
/// <param name="urls"></param>
/// <returns></returns>
protected virtual ApiHttpClient CreateHttp(String urls) => new(urls) { Log = Log };
protected virtual ApiHttpClient CreateHttp(String urls) => new(urls) { Log = Log, DefaultUserAgent = $"{_name}/v{_version}" };

/// <summary>创建RPC客户端</summary>
/// <param name="urls"></param>
Expand Down

0 comments on commit 320b983

Please sign in to comment.