tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
HttpClientFactory.cs
Go to the documentation of this file.
1using System;
2using System.Net.Http.Headers;
3
5{
10 {
13 {
14 var client = new HttpClient();
15 try
16 {
17 client.DefaultRequestHeaders.UserAgent.Add(userAgent);
18 return client;
19 }
20 catch
21 {
22 client.Dispose();
23 throw;
24 }
25 }
26
30 readonly ProductInfoHeaderValue userAgent;
31
36 public HttpClientFactory(ProductInfoHeaderValue userAgent)
37 {
38 this.userAgent = userAgent ?? throw new ArgumentNullException(nameof(userAgent));
39 }
40 }
41}
IAbstractHttpClientFactory that creates HttpClients.
IHttpClient CreateClient()
Create a IHttpClient.A new IHttpClient.
readonly ProductInfoHeaderValue userAgent
The ProductInfoHeaderValue used as created client's User-Agent header on request.
HttpClientFactory(ProductInfoHeaderValue userAgent)
Initializes a new instance of the HttpClientFactory class.