hook to create HttpClientHandler from custom factory
This commit is contained in:
parent
ad478bef44
commit
e9b9c65ec8
@ -10,10 +10,20 @@ namespace Flurl.Http.Configuration
|
||||
/// </summary>
|
||||
public class DefaultHttpClientFactory : IHttpClientFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Override in custom factory to customize the creation of HttpClient.
|
||||
/// </summary>
|
||||
public virtual HttpClient CreateClient(Url url) {
|
||||
return new HttpClient(new FlurlMessageHandler()) {
|
||||
return new HttpClient(new FlurlMessageHandler(CreateClientHandler())) {
|
||||
Timeout = FlurlHttp.Configuration.DefaultTimeout
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override in custom factory to customize the creation of HttpClientHandler.
|
||||
/// </summary>
|
||||
public virtual HttpClientHandler CreateClientHandler() {
|
||||
return new HttpClientHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,10 @@ namespace Flurl.Http.Configuration
|
||||
/// <summary>
|
||||
/// HTTP message handler used by default in all Flurl-created HttpClients.
|
||||
/// </summary>
|
||||
internal class FlurlMessageHandler : DelegatingHandler
|
||||
public class FlurlMessageHandler : DelegatingHandler
|
||||
{
|
||||
public FlurlMessageHandler(HttpMessageHandler innerHandler) : base(innerHandler) { }
|
||||
|
||||
public FlurlMessageHandler() : base(new HttpClientHandler()) { }
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) {
|
||||
var call = new HttpCall {
|
||||
Request = request
|
||||
|
@ -3,4 +3,4 @@
|
||||
[assembly: AssemblyTitle("Flurl.Http")]
|
||||
[assembly: AssemblyDescription("A fluent, testable HTTP client library that extends Flurl's URL builder chain.")]
|
||||
[assembly: AssemblyCopyright("Copyright © Todd Menier 2014")]
|
||||
[assembly: AssemblyVersion("0.2.4")]
|
||||
[assembly: AssemblyVersion("0.2.5")]
|
||||
|
@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>Flurl.Http</id>
|
||||
<version>0.2.4</version>
|
||||
<version>0.2.5</version>
|
||||
<title>Flurl.Http</title>
|
||||
<authors>Todd Menier</authors>
|
||||
<projectUrl>http://tmenier.github.io/Flurl</projectUrl>
|
||||
@ -12,6 +12,7 @@
|
||||
A fluent, portable, testable HTTP client library that extends Flurl's URL builder chain.
|
||||
</description>
|
||||
<releaseNotes>
|
||||
0.2.5 - Added hook to create HttpClientHandler from custom factory, updated Flurl dependency.
|
||||
0.2.4 - Updated Flurl dependency for PCL to 1.0.2.
|
||||
0.2.3 - New properties added to HttpCall: Url, Completed, Succeeded, HttpStatus.
|
||||
0.2.2 - Updated Flurl dependency for PCL to 1.0.1.
|
||||
|
Loading…
x
Reference in New Issue
Block a user