33using System . Diagnostics ;
44using System . Diagnostics . CodeAnalysis ;
55using System . Net ;
6+ using System . Net . Http . Headers ;
67using System . Reflection ;
78using System . Runtime . InteropServices ;
89using System . Text ;
10+ using Hardware . Info ;
911using Intersect . Core ;
12+ using Intersect . Framework . SystemInformation ;
1013using Intersect . Web ;
1114using Microsoft . Extensions . Logging ;
1215using Newtonsoft . Json ;
@@ -120,6 +123,15 @@ public UpdaterStatus TryGetManifest(out UpdateManifest? updateManifest, int reat
120123 try
121124 {
122125 using IntersectHttpClient httpClient = new ( _baseUrl , _tokenResponse ) ;
126+ httpClient . DefaultRequestHeaders . UserAgent . Clear ( ) ;
127+
128+ var applicationContext = ApplicationContext . CurrentContext ;
129+ var productName = applicationContext . Name . Replace ( " " , "_" ) ;
130+ var productVersion = applicationContext . Version ;
131+ var platformComment = new ProductInfoHeaderValue ( comment : $ "({ PlatformInformation . RuntimeIdentifier } )") ;
132+ ProductInfoHeaderValue productInfoHeaderValue = new ( productName , productVersion ) ;
133+ httpClient . DefaultRequestHeaders . UserAgent . Add ( productInfoHeaderValue ) ;
134+ httpClient . DefaultRequestHeaders . UserAgent . Add ( platformComment ) ;
123135
124136 HttpResponseMessage ? responseMessage = default ;
125137
@@ -129,9 +141,24 @@ public UpdaterStatus TryGetManifest(out UpdateManifest? updateManifest, int reat
129141 {
130142 try
131143 {
144+ KeyValuePair < string , string > [ ] queryParameters =
145+ [
146+ new ( "token" , Environment . TickCount . ToString ( ) ) ,
147+ new ( "rid" , PlatformInformation . RuntimeIdentifier ) ,
148+ ] ;
149+ UriBuilder requestUriBuilder = new ( _manifestUrl ?? throw new InvalidOperationException ( ) )
150+ {
151+ Query = string . Join (
152+ "&" ,
153+ queryParameters . Select (
154+ p => string . Join ( '=' , Uri . EscapeDataString ( p . Key ) , Uri . EscapeDataString ( p . Value ) )
155+ )
156+ ) ,
157+ } ;
158+ var requestUri = requestUriBuilder . Uri ;
132159 using HttpRequestMessage requestMessage = new (
133160 HttpMethod . Get ,
134- $ " { _manifestUrl } ?token= { Environment . TickCount } "
161+ requestUri
135162 ) ;
136163
137164 ApplicationContext . CurrentContext . Logger . LogInformation (
0 commit comments