@@ -27,6 +27,7 @@ public class DefaultHttpWorkerService : IHttpWorkerService
27
27
private readonly IHttpProxyService _httpProxyService ;
28
28
private readonly ScriptInvocationResult _successfulInvocationResult ;
29
29
private readonly Uri _destinationPrefix ;
30
+ private readonly string _userAgentString ;
30
31
31
32
public DefaultHttpWorkerService ( IOptions < HttpWorkerOptions > httpWorkerOptions , ILoggerFactory loggerFactory , IEnvironment environment ,
32
33
IOptions < ScriptJobHostOptions > scriptHostOptions , IHttpProxyService httpProxyService )
@@ -60,6 +61,7 @@ internal DefaultHttpWorkerService(HttpClient httpClient, IOptions<HttpWorkerOpti
60
61
} ;
61
62
62
63
_destinationPrefix = new UriBuilder ( WorkerConstants . HttpScheme , WorkerConstants . HostName , _httpWorkerOptions . Port ) . Uri ;
64
+ _userAgentString = $ "{ HttpWorkerConstants . UserAgentHeaderValue } /{ ScriptHost . Version } ";
63
65
}
64
66
65
67
private static HttpClient CreateHttpClient ( IOptions < HttpWorkerOptions > httpWorkerOptions )
@@ -203,10 +205,10 @@ internal void AddHeaders(HttpRequestMessage httpRequest, string invocationId)
203
205
{
204
206
httpRequest . Headers . Add ( HttpWorkerConstants . HostVersionHeaderName , ScriptHost . Version ) ;
205
207
httpRequest . Headers . Add ( HttpWorkerConstants . InvocationIdHeaderName , invocationId ) ;
206
- httpRequest . Headers . UserAgent . ParseAdd ( $ " { HttpWorkerConstants . UserAgentHeaderValue } / { ScriptHost . Version } " ) ;
208
+ httpRequest . Headers . UserAgent . ParseAdd ( _userAgentString ) ;
207
209
}
208
210
209
- internal void AddProxyingHeaders ( HttpRequest httpRequest , string invocationId )
211
+ private void AddProxyingHeaders ( HttpRequest httpRequest , string invocationId )
210
212
{
211
213
httpRequest . Headers . TryAdd ( HttpWorkerConstants . HostVersionHeaderName , ScriptHost . Version ) ;
212
214
@@ -215,9 +217,7 @@ internal void AddProxyingHeaders(HttpRequest httpRequest, string invocationId)
215
217
httpRequest . Headers [ HttpWorkerConstants . InvocationIdHeaderName ] = invocationId ;
216
218
}
217
219
218
- var userAgent = $ "{ HttpWorkerConstants . UserAgentHeaderValue } /{ ScriptHost . Version } ";
219
- httpRequest . Headers . Remove ( "User-Agent" ) ;
220
- httpRequest . Headers . Append ( "User-Agent" , userAgent ) ;
220
+ httpRequest . Headers . UserAgent = _userAgentString ;
221
221
}
222
222
223
223
internal string GetPathValue ( HttpWorkerOptions httpWorkerOptions , string functionName , HttpRequest httpRequest )
0 commit comments