don't auto-redirect HttpClient

This commit is contained in:
Collin M. Barrett 2019-07-02 21:50:39 -05:00
parent 97db616f88
commit fd4a037f94

View file

@ -1,4 +1,5 @@
using FilterLists.Agent.AppSettings;
using System.Net.Http;
using FilterLists.Agent.AppSettings;
using FilterLists.Agent.Core.Interfaces;
using FilterLists.Agent.Infrastructure.Clients;
using FilterLists.Agent.Infrastructure.Repositories;
@ -17,7 +18,11 @@ public static void RegisterAgentServices(this IServiceCollection services)
services.AddConfiguration();
services.AddLoggingCustom();
services.AddMediatR(typeof(Program).Assembly);
services.AddHttpClient<AgentHttpClient>();
services.AddHttpClient<AgentHttpClient>().ConfigureHttpMessageHandlerBuilder(b =>
{
b.PrimaryHandler = new HttpClientHandler {AllowAutoRedirect = false};
b.Build();
});
services.AddSingleton<IFilterListsApiClient, FilterListsApiClient>();
services.AddSingleton<IAgentGitHubClient, AgentGitHubClient>();
services.AddTransient<IListInfoRepository, ListInfoRepository>();