//----------------------------------------------------------------------- // // Copyright (c) Andrew Arnott. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth { using System; using System.Net.Http; /// /// 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 WebRequestHandler 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(PortableUtilities.LibraryVersionHeader); return client; } } }