U4-11570 - changed WebClient() from created inside of using to check if null and then creating it
This commit is contained in:
@@ -20,9 +20,10 @@ using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
|
||||
|
||||
public class CanvasDesignerController : UmbracoApiController
|
||||
{
|
||||
private static WebClient _webClient;
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage GetGoogleFont()
|
||||
@@ -35,10 +36,10 @@ namespace Umbraco.Web.Editors
|
||||
var googleWebFontAPIURL = string.Format("https://www.googleapis.com/webfonts/v1/webfonts?key={0}", APIKey);
|
||||
|
||||
var response = "{}";
|
||||
using (var client = new System.Net.WebClient())
|
||||
{
|
||||
response = client.DownloadString(new Uri(googleWebFontAPIURL));
|
||||
}
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
|
||||
response = _webClient.DownloadString(new Uri(googleWebFontAPIURL));
|
||||
|
||||
var resp = Request.CreateResponse();
|
||||
resp.Content = new StringContent(response);
|
||||
@@ -59,7 +60,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
// Prepare string parameter result
|
||||
string[] paramLines = paramBlock.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
IList<string> parameters = new List<string>();
|
||||
IList<string> parameters = new List<string>();
|
||||
foreach (var line in paramLines)
|
||||
{
|
||||
if (!line.Contains("@import"))
|
||||
@@ -121,4 +122,4 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using Umbraco.Core;
|
||||
@@ -80,7 +81,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new System.Net.WebClient();
|
||||
var client = new WebClient();
|
||||
var values = new NameValueCollection { { "name", admin.Name }, { "email", admin.Email} };
|
||||
client.UploadValues("https://shop.umbraco.com/base/Ecom/SubmitEmail/installer.aspx", values);
|
||||
}
|
||||
|
||||
@@ -12,18 +12,20 @@ namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
//TODO: Make all Http calls async
|
||||
|
||||
public abstract class AbstractOEmbedProvider: IEmbedProvider
|
||||
public abstract class AbstractOEmbedProvider : IEmbedProvider
|
||||
{
|
||||
private static WebClient _webClient;
|
||||
|
||||
public virtual bool SupportsDimensions
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
[ProviderSetting]
|
||||
public string APIEndpoint{ get;set; }
|
||||
public string APIEndpoint { get; set; }
|
||||
|
||||
[ProviderSetting]
|
||||
public Dictionary<string, string> RequestParams{ get;set; }
|
||||
public Dictionary<string, string> RequestParams { get; set; }
|
||||
|
||||
public abstract string GetMarkup(string url, int maxWidth, int maxHeight);
|
||||
|
||||
@@ -51,10 +53,9 @@ namespace Umbraco.Web.Media.EmbedProviders
|
||||
|
||||
public virtual string DownloadResponse(string url)
|
||||
{
|
||||
using (var webClient = new WebClient())
|
||||
{
|
||||
return webClient.DownloadString(url);
|
||||
}
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
return _webClient.DownloadString(url);
|
||||
}
|
||||
|
||||
public virtual T GetJsonResponse<T>(string url) where T : class
|
||||
@@ -79,4 +80,4 @@ namespace Umbraco.Web.Media.EmbedProviders
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,9 @@ namespace umbraco.presentation
|
||||
[Obsolete("This is no longer used and will be removed in future versions")]
|
||||
public class keepAliveService
|
||||
{
|
||||
private static WebClient _webClient;
|
||||
//NOTE: sender will be the umbraco ApplicationContext
|
||||
public static void PingUmbraco(object sender)
|
||||
public static void PingUmbraco(object sender)
|
||||
{
|
||||
if (sender == null || !(sender is ApplicationContext))
|
||||
return;
|
||||
@@ -21,10 +22,9 @@ namespace umbraco.presentation
|
||||
var url = appContext.UmbracoApplicationUrl + "/ping.aspx";
|
||||
try
|
||||
{
|
||||
using (var wc = new WebClient())
|
||||
{
|
||||
wc.DownloadString(url);
|
||||
}
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
_webClient.DownloadString(url);
|
||||
}
|
||||
catch(Exception ee)
|
||||
{
|
||||
@@ -32,4 +32,4 @@ namespace umbraco.presentation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Umbraco.Core.Logging;
|
||||
using System.Net.Http;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace dashboardUtilities
|
||||
@@ -14,6 +15,8 @@ namespace dashboardUtilities
|
||||
|
||||
public partial class FeedProxy : UmbracoEnsuredPage
|
||||
{
|
||||
private static WebClient _webClient;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
@@ -31,9 +34,10 @@ namespace dashboardUtilities
|
||||
&& feedProxyXml.SelectSingleNode(string.Concat("//allow[@host = '", requestUri.Host, "']")) != null
|
||||
&& requestUri.Port == 80)
|
||||
{
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
var response = client.DownloadString(requestUri);
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
|
||||
var response = _webClient.DownloadString(requestUri);
|
||||
|
||||
if (string.IsNullOrEmpty(response) == false)
|
||||
{
|
||||
@@ -41,7 +45,7 @@ namespace dashboardUtilities
|
||||
Response.ContentType = Request.CleanForXss("type") ?? MediaTypeNames.Text.Xml;
|
||||
Response.Write(response);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -57,4 +61,4 @@ namespace dashboardUtilities
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using umbraco.cms.businesslogic.web;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Diagnostics;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using umbraco.cms.businesslogic.template;
|
||||
using umbraco.interfaces;
|
||||
using Umbraco.Core.Events;
|
||||
@@ -685,7 +686,7 @@ namespace umbraco.cms.businesslogic.packager
|
||||
if (Directory.Exists(IOHelper.MapPath(SystemDirectories.Packages)) == false)
|
||||
Directory.CreateDirectory(IOHelper.MapPath(SystemDirectories.Packages));
|
||||
|
||||
var wc = new System.Net.WebClient();
|
||||
var wc = new WebClient();
|
||||
|
||||
wc.DownloadFile(
|
||||
"http://" + PackageServer + "/fetch?package=" + Package.ToString(),
|
||||
|
||||
Reference in New Issue
Block a user