diff --git a/OpenTween/Connection/IApiConnectionLegacy.cs b/OpenTween/Connection/IApiConnectionLegacy.cs index 9b9e7d8c0..839ad462e 100644 --- a/OpenTween/Connection/IApiConnectionLegacy.cs +++ b/OpenTween/Connection/IApiConnectionLegacy.cs @@ -34,8 +34,6 @@ public interface IApiConnectionLegacy : IApiConnection, IDisposable { Task GetAsync(Uri uri, IDictionary? param, string? endpointName); - Task GetStreamingStreamAsync(Uri uri, IDictionary? param); - Task> PostLazyAsync(Uri uri, IDictionary? param); Task> PostLazyAsync(Uri uri, IDictionary? param, IDictionary? media); diff --git a/OpenTween/Connection/TwitterApiConnection.cs b/OpenTween/Connection/TwitterApiConnection.cs index bf81c2363..0e860607c 100644 --- a/OpenTween/Connection/TwitterApiConnection.cs +++ b/OpenTween/Connection/TwitterApiConnection.cs @@ -54,7 +54,6 @@ public static string RestApiHost internal HttpClient Http; internal HttpClient HttpUpload; - internal HttpClient HttpStreaming; internal ITwitterCredential Credential { get; } @@ -71,16 +70,13 @@ public TwitterApiConnection(ITwitterCredential credential) Networking.WebProxyChanged += this.Networking_WebProxyChanged; } - [MemberNotNull(nameof(Http), nameof(HttpUpload), nameof(HttpStreaming))] + [MemberNotNull(nameof(Http), nameof(HttpUpload))] private void InitializeHttpClients() { this.Http = InitializeHttpClient(this.Credential); this.HttpUpload = InitializeHttpClient(this.Credential); this.HttpUpload.Timeout = Networking.UploadImageTimeout; - - this.HttpStreaming = InitializeHttpClient(this.Credential, disableGzip: true); - this.HttpStreaming.Timeout = Timeout.InfiniteTimeSpan; } public async Task SendAsync(IHttpRequest request) @@ -164,35 +160,6 @@ private void ThrowIfRateLimitExceeded(string endpointName) } } - public async Task GetStreamingStreamAsync(Uri uri, IDictionary? param) - { - var requestUri = new Uri(RestApiBase, uri); - - if (param != null) - requestUri = new Uri(requestUri, "?" + MyCommon.BuildQueryString(param)); - - try - { - var request = new HttpRequestMessage(HttpMethod.Get, requestUri); - var response = await this.HttpStreaming.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) - .ConfigureAwait(false); - - await TwitterApiConnection.CheckStatusCode(response) - .ConfigureAwait(false); - - return await response.Content.ReadAsStreamAsync() - .ConfigureAwait(false); - } - catch (HttpRequestException ex) - { - throw TwitterApiException.CreateFromException(ex); - } - catch (OperationCanceledException ex) - { - throw TwitterApiException.CreateFromException(ex); - } - } - public async Task> PostLazyAsync(Uri uri, IDictionary? param) { var requestUri = new Uri(RestApiBase, uri); @@ -438,7 +405,6 @@ protected virtual void Dispose(bool disposing) Networking.WebProxyChanged -= this.Networking_WebProxyChanged; this.Http.Dispose(); this.HttpUpload.Dispose(); - this.HttpStreaming.Dispose(); } } @@ -524,17 +490,13 @@ await TwitterApiConnection.CheckStatusCode(response) } } - private static HttpClient InitializeHttpClient(ITwitterCredential credential, bool disableGzip = false) + private static HttpClient InitializeHttpClient(ITwitterCredential credential) { var builder = Networking.CreateHttpClientBuilder(); - builder.SetupHttpClientHandler(x => - { - x.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); - - if (disableGzip) - x.AutomaticDecompression = DecompressionMethods.None; - }); + builder.SetupHttpClientHandler( + x => x.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache) + ); builder.AddHandler(x => credential.CreateHttpHandler(x));