public static HttpWebRequest CreateHttpWebRequest(Uri uri, HttpMethod httpMethod, TimeSpan timeout, string contentType = null) { var httpWebRequest = (HttpWebRequest)WebRequest.Create(uri); httpWebRequest.Method = httpMethod.ToString(); httpWebRequest.Timeout = (int)timeout.TotalMilliseconds; httpWebRequest.UserAgent = $"{Constants.ApplicationName} - Version: {AssemblyExtensions.GetStringVersion()}"; if (!string.IsNullOrWhiteSpace(contentType)) { httpWebRequest.ContentType = contentType; } return(httpWebRequest); }