Skip to content

Commit

Permalink
Keep old changes
Browse files Browse the repository at this point in the history
  • Loading branch information
raman-m committed Apr 7, 2024
1 parent e01f7a1 commit b0b7f66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/Ocelot/Requester/HttpClientBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

namespace Ocelot.Requester
{
public interface IHttpClientBuilder { }
public interface IHttpClientCache
{
IHttpClient Get(DownstreamRoute cacheKey);
void Set(DownstreamRoute cacheKey, IHttpClient client, TimeSpan span);
}

public class HttpClientBuilder : IHttpClientBuilder
{
private readonly IDelegatingHandlerHandlerFactory _factory;
Expand Down Expand Up @@ -65,7 +72,7 @@ public IHttpClient Create(DownstreamRoute downstreamRoute)
Timeout = timeout,
};

_client = new HttpClientWrapper(_httpClient, downstreamRoute.ConnectionClose);
_client = new HttpClientWrapper(_httpClient, downstreamRoute.ConnectionClose); // TODO

return _client;
}
Expand Down
8 changes: 5 additions & 3 deletions src/Ocelot/Requester/HttpClientWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@

namespace Ocelot.Requester
{
public interface IHttpClient { }

/// <summary>
/// This class was made to make unit testing easier when HttpClient is used.
/// </summary>
public class HttpClientWrapper : IHttpClient
{
public HttpClient Client { get; }

public bool ConnectionClose { get; }
public bool ConnectionClose { get; } // TODO

public HttpClientWrapper(HttpClient client, bool connectionClose = false)
{
Client = client;
ConnectionClose = connectionClose;
ConnectionClose = connectionClose; // TODO
}

public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default)
{
request.Headers.ConnectionClose = ConnectionClose;
request.Headers.ConnectionClose = ConnectionClose; // TODO
return Client.SendAsync(request, cancellationToken);
}
}
Expand Down

0 comments on commit b0b7f66

Please sign in to comment.