Skip to content

Commit

Permalink
Add user agent header (#581)
Browse files Browse the repository at this point in the history
* Add user agent

* Update OracleHttpsProtocol.cs

* Update src/OracleService/Protocols/OracleHttpsProtocol.cs

Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>

Co-authored-by: Erik Zhang <erik@neo.org>
Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>
  • Loading branch information
3 people committed Apr 12, 2021
1 parent 43f08ed commit 057ff46
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/OracleService/Protocols/OracleHttpsProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -12,6 +14,13 @@ class OracleHttpsProtocol : IOracleProtocol
{
private readonly HttpClient client = new HttpClient();

public OracleHttpsProtocol()
{
CustomAttributeData attribute = Assembly.GetExecutingAssembly().CustomAttributes.First(p => p.AttributeType == typeof(AssemblyInformationalVersionAttribute));
string version = (string)attribute.ConstructorArguments[0].Value;
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("NeoOracleService", version));
}

public void Configure()
{
client.DefaultRequestHeaders.Accept.Clear();
Expand Down

0 comments on commit 057ff46

Please sign in to comment.