tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
HttpClient.cs
Go to the documentation of this file.
1using System;
2using System.Net.Http;
3using System.Net.Http.Headers;
4using System.Threading;
5using System.Threading.Tasks;
6
8{
10 public sealed class HttpClient : IHttpClient
11 {
13 public TimeSpan Timeout
14 {
15 get => httpClient.Timeout;
16 set => httpClient.Timeout = value;
17 }
18
21
25 readonly System.Net.Http.HttpClient httpClient;
26
31 public HttpClient(System.Net.Http.HttpClient implementation)
32 {
33 httpClient = implementation ?? throw new ArgumentNullException(nameof(implementation));
34 }
35
39 public HttpClient()
40 : this(new System.Net.Http.HttpClient())
41 {
42 }
43
45 public void Dispose() => httpClient.Dispose();
46
48 public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
49 => httpClient.SendAsync(request, completionOption, cancellationToken);
50 }
51}
TimeSpan Timeout
The request timeout.
Definition HttpClient.cs:14
Task< HttpResponseMessage > SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
Send an HTTP request.A Task<TResult> resulting in the HttpResponseMessage of the request.
HttpClient()
Initializes a new instance of the HttpClient class.
Definition HttpClient.cs:39
HttpRequestHeaders DefaultRequestHeaders
The HttpRequestHeaders used on every request.
Definition HttpClient.cs:20
readonly System.Net.Http.HttpClient httpClient
The real System.Net.Http.HttpClient.
Definition HttpClient.cs:25
HttpClient(System.Net.Http.HttpClient implementation)
Initializes a new instance of the HttpClient class.
Definition HttpClient.cs:31