mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 17:28:16 +08:00
* Add ability to specify whether to UseProxy or not on ReRoutes (#390) * Remove useProxy default value from HttpHandlerOptions constructor
This commit is contained in:

committed by
Tom Pallister

parent
0f2a9c1d0d
commit
87c13bd9b4
@ -15,10 +15,10 @@ namespace Ocelot.Configuration.Creator
|
||||
|
||||
public HttpHandlerOptions Create(FileHttpHandlerOptions options)
|
||||
{
|
||||
var useTracing = _tracer.GetType() != typeof(FakeServiceTracer) && options.UseTracing;
|
||||
var useTracing = _tracer.GetType() != typeof(FakeServiceTracer) && options.UseTracing;
|
||||
|
||||
return new HttpHandlerOptions(options.AllowAutoRedirect,
|
||||
options.UseCookieContainer, useTracing);
|
||||
options.UseCookieContainer, useTracing, options.UseProxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,16 @@
|
||||
public FileHttpHandlerOptions()
|
||||
{
|
||||
AllowAutoRedirect = false;
|
||||
UseCookieContainer = false;
|
||||
UseCookieContainer = false;
|
||||
UseProxy = true;
|
||||
}
|
||||
|
||||
public bool AllowAutoRedirect { get; set; }
|
||||
|
||||
public bool UseCookieContainer { get; set; }
|
||||
|
||||
public bool UseTracing { get; set; }
|
||||
public bool UseTracing { get; set; }
|
||||
|
||||
public bool UseProxy { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,12 @@
|
||||
/// </summary>
|
||||
public class HttpHandlerOptions
|
||||
{
|
||||
public HttpHandlerOptions(bool allowAutoRedirect, bool useCookieContainer, bool useTracing)
|
||||
public HttpHandlerOptions(bool allowAutoRedirect, bool useCookieContainer, bool useTracing, bool useProxy)
|
||||
{
|
||||
AllowAutoRedirect = allowAutoRedirect;
|
||||
UseCookieContainer = useCookieContainer;
|
||||
UseTracing = useTracing;
|
||||
UseProxy = useProxy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -23,9 +24,14 @@
|
||||
/// </summary>
|
||||
public bool UseCookieContainer { get; private set; }
|
||||
|
||||
// <summary>
|
||||
/// <summary>
|
||||
/// Specify is handler has to use a opentracing
|
||||
/// </summary>
|
||||
public bool UseTracing { get; private set; }
|
||||
public bool UseTracing { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specify if handler has to use a proxy
|
||||
/// </summary>
|
||||
public bool UseProxy { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
private bool _allowAutoRedirect;
|
||||
private bool _useCookieContainer;
|
||||
private bool _useTracing;
|
||||
private bool _useProxy;
|
||||
|
||||
public HttpHandlerOptionsBuilder WithAllowAutoRedirect(bool input)
|
||||
{
|
||||
@ -24,9 +25,15 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpHandlerOptionsBuilder WithUseProxy(bool useProxy)
|
||||
{
|
||||
_useProxy = useProxy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpHandlerOptions Build()
|
||||
{
|
||||
return new HttpHandlerOptions(_allowAutoRedirect, _useCookieContainer, _useTracing);
|
||||
return new HttpHandlerOptions(_allowAutoRedirect, _useCookieContainer, _useTracing, _useProxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ namespace Ocelot.Requester
|
||||
{
|
||||
AllowAutoRedirect = context.DownstreamReRoute.HttpHandlerOptions.AllowAutoRedirect,
|
||||
UseCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer,
|
||||
UseProxy = context.DownstreamReRoute.HttpHandlerOptions.UseProxy
|
||||
};
|
||||
}
|
||||
|
||||
@ -98,6 +99,7 @@ namespace Ocelot.Requester
|
||||
{
|
||||
AllowAutoRedirect = context.DownstreamReRoute.HttpHandlerOptions.AllowAutoRedirect,
|
||||
UseCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer,
|
||||
UseProxy = context.DownstreamReRoute.HttpHandlerOptions.UseProxy,
|
||||
CookieContainer = new CookieContainer()
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user