private OAuthHttpClient(OAuthHttpMessageHandler authenticator) : base(authenticator, true) { this.m_authenticator = authenticator; // Set the overall timeout if (HttpContextSettings.OperationTimeout > TimeSpan.Zero) { this.Timeout = HttpContextSettings.OperationTimeout; } // Set the default user agent this.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Duplicati", USER_AGENT_VERSION)); }
/// <summary> /// Create a message handler with the global timeout / certificate settings. /// </summary> /// <param name="authid">OAuth Auth-ID</param> /// <param name="protocolKey">Protocol key</param> /// <returns>Http message handler</returns> private static OAuthHttpMessageHandler CreateMessageHandler(string authid, string protocolKey) { OAuthHttpMessageHandler handler = new OAuthHttpMessageHandler(authid, protocolKey); // Set the read/write timeout if (HttpContextSettings.OperationTimeout > TimeSpan.Zero) { handler.ReadWriteTimeout = (int)HttpContextSettings.ReadWriteTimeout.TotalMilliseconds; } // Set the certificate validator if (HttpContextSettings.CertificateValidator != null) { handler.ServerCertificateValidationCallback = HttpContextSettings.CertificateValidator.ValidateServerCertficate; } return(handler); }
private OAuthHttpClient(OAuthHttpMessageHandler authenticator) : base(authenticator, true) { this.m_authenticator = authenticator; // Set the overall timeout if (HttpContextSettings.OperationTimeout > TimeSpan.Zero) { this.Timeout = HttpContextSettings.OperationTimeout; } // We would also set AllowReadStreamBuffering = HttpContextSettings.BufferRequests, except HttpClient doesn't appear to expose this. // However, starting in .NET 4.5, it looks like HttpClient doesn't buffer by default. // https://www.strathweb.com/2012/09/dealing-with-large-files-in-asp-net-web-api/ // Set the default user agent this.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Duplicati", USER_AGENT_VERSION)); }