//-----------------------------------------------------------------------
//
// Copyright (c) Andrew Arnott. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Cache;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
///
/// Creates default instances of required dependencies.
///
public class DefaultOAuthHostFactories : IHostFactories {
///
/// Initializes a new instance of a concrete derivation of
/// to be used for outbound HTTP traffic.
///
/// An instance of .
///
/// An instance of is recommended where available;
/// otherwise an instance of is recommended.
///
public virtual HttpMessageHandler CreateHttpMessageHandler() {
var handler = new HttpClientHandler();
return handler;
}
///
/// Initializes a new instance of the class
/// to be used for outbound HTTP traffic.
///
/// The handler to pass to the constructor.
/// May be null to use the default that would be provided by .
///
/// An instance of .
///
public HttpClient CreateHttpClient(HttpMessageHandler handler) {
handler = handler ?? this.CreateHttpMessageHandler();
var client = new HttpClient(handler);
client.DefaultRequestHeaders.UserAgent.Add(Util.LibraryVersionHeader);
return client;
}
}
}