diff --git a/Refit/ApiResponse.cs b/Refit/ApiResponse.cs index 8df834cd6..259a58123 100644 --- a/Refit/ApiResponse.cs +++ b/Refit/ApiResponse.cs @@ -42,10 +42,9 @@ public sealed class ApiResponse( T? content, RefitSettings settings, ApiException? error = null - ) : IApiResponse, IApiResponse + ) : IApiResponse { - readonly HttpResponseMessage response = - response ?? throw new ArgumentNullException(nameof(response)); + readonly HttpResponseMessage response = response ?? throw new ArgumentNullException(nameof(response)); bool disposed; /// @@ -151,45 +150,29 @@ void Dispose(bool disposing) } /// - public interface IApiResponse : IApiResponseBase + public interface IApiResponse : IApiResponse { /// /// Deserialized request content as . /// T? Content { get; } + } + /// + /// Base interface used to represent an API response. + /// + public interface IApiResponse : IDisposable + { /// - /// Indicates whether the request was successful. + /// HTTP response headers. /// -#if NET6_0_OR_GREATER - [MemberNotNullWhen(true, nameof(ContentHeaders))] - [MemberNotNullWhen(false, nameof(Error))] - [MemberNotNullWhen(true, nameof(Content))] -#endif - bool IsSuccessStatusCode { get; } + HttpResponseHeaders Headers { get; } /// /// HTTP response content headers as defined in RFC 2616. /// HttpContentHeaders? ContentHeaders { get; } - /// - /// The object in case of unsuccessful response. - /// - [SuppressMessage( - "Naming", - "CA1716:Identifiers should not match keywords", - Justification = "By Design" - )] - ApiException? Error { get; } - } - - /// - /// IApiResponse. - /// - /// - public interface IApiResponse : IApiResponseBase - { /// /// Indicates whether the request was successful. /// @@ -199,32 +182,6 @@ public interface IApiResponse : IApiResponseBase #endif bool IsSuccessStatusCode { get; } - /// - /// HTTP response content headers as defined in RFC 2616. - /// - HttpContentHeaders? ContentHeaders { get; } - - /// - /// The object in case of unsuccessful response. - /// - [SuppressMessage( - "Naming", - "CA1716:Identifiers should not match keywords", - Justification = "By Design" - )] - ApiException? Error { get; } - } - - /// - /// Base interface used to represent an API response. - /// - public interface IApiResponseBase : IDisposable - { - /// - /// HTTP response headers. - /// - HttpResponseHeaders Headers { get; } - /// /// HTTP response status code. /// @@ -244,5 +201,15 @@ public interface IApiResponseBase : IDisposable /// HTTP Message version. /// Version Version { get; } + + /// + /// The object in case of unsuccessful response. + /// + [SuppressMessage( + "Naming", + "CA1716:Identifiers should not match keywords", + Justification = "By Design" + )] + ApiException? Error { get; } } } diff --git a/Refit/RequestBuilderImplementation.cs b/Refit/RequestBuilderImplementation.cs index 1e47bbe3e..e8dea6165 100644 --- a/Refit/RequestBuilderImplementation.cs +++ b/Refit/RequestBuilderImplementation.cs @@ -447,13 +447,6 @@ CancellationToken cancellationToken } else { - using var stream = await content - .ReadAsStreamAsync(cancellationToken) - .ConfigureAwait(false); - if (stream.CanSeek) - { - await content.LoadIntoBufferAsync().ConfigureAwait(false); - } result = await serializer .FromHttpContentAsync(content, cancellationToken) .ConfigureAwait(false);