8000 Revert #1705 by ChrisPulman · Pull Request #1750 · reactiveui/refit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Revert #1705 #1750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
0