Skip to content

Commit

Permalink
Revert #1705 (#1750)
Browse files Browse the repository at this point in the history
* Revert #1705

* Revert #1705
  • Loading branch information
ChrisPulman authored Jun 30, 2024
1 parent ea1cc52 commit 56375c4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 61 deletions.
75 changes: 21 additions & 54 deletions Refit/ApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ public sealed class ApiResponse<T>(
T? content,
RefitSettings settings,
ApiException? error = null
) : IApiResponse<T>, IApiResponse
) : IApiResponse<T>
{
readonly HttpResponseMessage response =
response ?? throw new ArgumentNullException(nameof(response));
readonly HttpResponseMessage response = response ?? throw new ArgumentNullException(nameof(response));
bool disposed;

/// <summary>
Expand Down Expand Up @@ -151,45 +150,29 @@ void Dispose(bool disposing)
}

/// <inheritdoc/>
public interface IApiResponse<out T> : IApiResponseBase
public interface IApiResponse<out T> : IApiResponse
{
/// <summary>
/// Deserialized request content as <typeparamref name="T"/>.
/// </summary>
T? Content { get; }
}

/// <summary>
/// Base interface used to represent an API response.
/// </summary>
public interface IApiResponse : IDisposable
{
/// <summary>
/// Indicates whether the request was successful.
/// HTTP response headers.
/// </summary>
#if NET6_0_OR_GREATER
[MemberNotNullWhen(true, nameof(ContentHeaders))]
[MemberNotNullWhen(false, nameof(Error))]
[MemberNotNullWhen(true, nameof(Content))]
#endif
bool IsSuccessStatusCode { get; }
HttpResponseHeaders Headers { get; }

/// <summary>
/// HTTP response content headers as defined in RFC 2616.
/// </summary>
HttpContentHeaders? ContentHeaders { get; }

/// <summary>
/// The <see cref="ApiException"/> object in case of unsuccessful response.
/// </summary>
[SuppressMessage(
"Naming",
"CA1716:Identifiers should not match keywords",
Justification = "By Design"
)]
ApiException? Error { get; }
}

/// <summary>
/// IApiResponse.
/// </summary>
/// <seealso cref="Refit.IApiResponseBase" />
public interface IApiResponse : IApiResponseBase
{
/// <summary>
/// Indicates whether the request was successful.
/// </summary>
Expand All @@ -199,32 +182,6 @@ public interface IApiResponse : IApiResponseBase
#endif
bool IsSuccessStatusCode { get; }

/// <summary>
/// HTTP response content headers as defined in RFC 2616.
/// </summary>
HttpContentHeaders? ContentHeaders { get; }

/// <summary>
/// The <see cref="ApiException"/> object in case of unsuccessful response.
/// </summary>
[SuppressMessage(
"Naming",
"CA1716:Identifiers should not match keywords",
Justification = "By Design"
)]
ApiException? Error { get; }
}

/// <summary>
/// Base interface used to represent an API response.
/// </summary>
public interface IApiResponseBase : IDisposable
{
/// <summary>
/// HTTP response headers.
/// </summary>
HttpResponseHeaders Headers { get; }

/// <summary>
/// HTTP response status code.
/// </summary>
Expand All @@ -244,5 +201,15 @@ public interface IApiResponseBase : IDisposable
/// HTTP Message version.
/// </summary>
Version Version { get; }

/// <summary>
/// The <see cref="ApiException"/> object in case of unsuccessful response.
/// </summary>
[SuppressMessage(
"Naming",
"CA1716:Identifiers should not match keywords",
Justification = "By Design"
)]
ApiException? Error { get; }
}
}
7 changes: 0 additions & 7 deletions Refit/RequestBuilderImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(content, cancellationToken)
.ConfigureAwait(false);
Expand Down

0 comments on commit 56375c4

Please sign in to comment.