Fixes #3036
Removes WebClient completely except for in an old legacy class that is not used for anything any more (umbraco.cms.businesslogic.packager.Installer.Fetch).
This commit is contained in:
@@ -1,29 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
using AutoMapper;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using umbraco;
|
||||
using Umbraco.Web.WebApi;
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Web;
|
||||
using System.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
|
||||
public class CanvasDesignerController : UmbracoApiController
|
||||
{
|
||||
private static WebClient _webClient;
|
||||
private static HttpClient _httpClient;
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage GetGoogleFont()
|
||||
@@ -35,17 +23,14 @@ namespace Umbraco.Web.Editors
|
||||
// Google Web Font JSON URL
|
||||
var googleWebFontAPIURL = string.Format("https://www.googleapis.com/webfonts/v1/webfonts?key={0}", APIKey);
|
||||
|
||||
var response = "{}";
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
|
||||
response = _webClient.DownloadString(new Uri(googleWebFontAPIURL));
|
||||
|
||||
var resp = Request.CreateResponse();
|
||||
resp.Content = new StringContent(response);
|
||||
resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
return resp;
|
||||
if (_httpClient == null)
|
||||
_httpClient = new HttpClient();
|
||||
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, googleWebFontAPIURL))
|
||||
{
|
||||
var response = _httpClient.SendAsync(request).Result;
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
||||
@@ -198,12 +198,11 @@ namespace Umbraco.Web.Install
|
||||
var packages = new List<Package>();
|
||||
try
|
||||
{
|
||||
var requestUri = string.Format("https://our.umbraco.com/webapi/StarterKit/Get/?umbracoVersion={0}",
|
||||
UmbracoVersion.Current);
|
||||
var requestUri = $"https://our.umbraco.com/webapi/StarterKit/Get/?umbracoVersion={UmbracoVersion.Current}";
|
||||
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
|
||||
using (var response = _httpClient.SendAsync(request).Result)
|
||||
{
|
||||
var response = _httpClient.SendAsync(request).Result;
|
||||
packages = response.Content.ReadAsAsync<IEnumerable<Package>>().Result.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Web.Install.Models;
|
||||
|
||||
namespace Umbraco.Web.Install.InstallSteps
|
||||
@@ -20,13 +21,12 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
/// error, etc... and the end-user refreshes the installer then we cannot show the user screen because they've already entered that information so instead we'll
|
||||
/// display a simple continue installation view.
|
||||
/// </remarks>
|
||||
[InstallSetupStep(InstallationType.NewInstall,
|
||||
"User", 20, "")]
|
||||
[InstallSetupStep(InstallationType.NewInstall, "User", 20, "")]
|
||||
internal class NewInstallStep : InstallSetupStep<UserModel>
|
||||
{
|
||||
private readonly HttpContextBase _http;
|
||||
private readonly ApplicationContext _applicationContext;
|
||||
private static WebClient _webClient;
|
||||
private static HttpClient _httpClient;
|
||||
|
||||
public NewInstallStep(HttpContextBase http, ApplicationContext applicationContext)
|
||||
{
|
||||
@@ -76,17 +76,18 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
admin.Username = user.Email.Trim();
|
||||
|
||||
_applicationContext.Services.UserService.Save(admin);
|
||||
|
||||
|
||||
|
||||
if (user.SubscribeToNewsLetter)
|
||||
{
|
||||
if (_httpClient == null)
|
||||
_httpClient = new HttpClient();
|
||||
|
||||
var values = new NameValueCollection { { "name", admin.Name }, { "email", admin.Email } };
|
||||
var content = new StringContent(JsonConvert.SerializeObject(values), Encoding.UTF8, "application/json");
|
||||
|
||||
try
|
||||
{
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
|
||||
var values = new NameValueCollection { { "name", admin.Name }, { "email", admin.Email} };
|
||||
_webClient.UploadValues("https://shop.umbraco.com/base/Ecom/SubmitEmail/installer.aspx", values);
|
||||
var response = _httpClient.PostAsync("https://shop.umbraco.com/base/Ecom/SubmitEmail/installer.aspx", content).Result;
|
||||
}
|
||||
catch { /* fail in silence */ }
|
||||
}
|
||||
@@ -113,13 +114,16 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
public override string View
|
||||
{
|
||||
get { return RequiresExecution(null)
|
||||
//the user UI
|
||||
? "user"
|
||||
//the continue install UI
|
||||
: "continueinstall"; }
|
||||
get
|
||||
{
|
||||
return RequiresExecution(null)
|
||||
//the user UI
|
||||
? "user"
|
||||
//the continue install UI
|
||||
: "continueinstall";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override bool RequiresExecution(UserModel model)
|
||||
{
|
||||
//now we have to check if this is really a new install, the db might be configured and might contain data
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Web.Media.EmbedProviders
|
||||
|
||||
public abstract class AbstractOEmbedProvider : IEmbedProvider
|
||||
{
|
||||
private static WebClient _webClient;
|
||||
private static HttpClient _httpClient;
|
||||
|
||||
public virtual bool SupportsDimensions
|
||||
{
|
||||
@@ -53,9 +53,14 @@ namespace Umbraco.Web.Media.EmbedProviders
|
||||
|
||||
public virtual string DownloadResponse(string url)
|
||||
{
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
return _webClient.DownloadString(url);
|
||||
if (_httpClient == null)
|
||||
_httpClient = new HttpClient();
|
||||
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, url))
|
||||
{
|
||||
var response = _httpClient.SendAsync(request).Result;
|
||||
return response.Content.ReadAsStringAsync().Result;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T GetJsonResponse<T>(string url) where T : class
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using System.Net.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
@@ -10,7 +8,7 @@ namespace umbraco.presentation
|
||||
[Obsolete("This is no longer used and will be removed in future versions")]
|
||||
public class keepAliveService
|
||||
{
|
||||
private static WebClient _webClient;
|
||||
private static HttpClient _httpClient;
|
||||
//NOTE: sender will be the umbraco ApplicationContext
|
||||
public static void PingUmbraco(object sender)
|
||||
{
|
||||
@@ -22,9 +20,13 @@ namespace umbraco.presentation
|
||||
var url = appContext.UmbracoApplicationUrl + "/ping.aspx";
|
||||
try
|
||||
{
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
_webClient.DownloadString(url);
|
||||
if (_httpClient == null)
|
||||
_httpClient = new HttpClient();
|
||||
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, url))
|
||||
{
|
||||
var response = _httpClient.SendAsync(request).Result;
|
||||
}
|
||||
}
|
||||
catch(Exception ee)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Net.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web;
|
||||
|
||||
@@ -6,54 +7,51 @@ namespace dashboardUtilities
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mime;
|
||||
using umbraco;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
public partial class FeedProxy : UmbracoEnsuredPage
|
||||
{
|
||||
private static WebClient _webClient;
|
||||
private static HttpClient _httpClient;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Request.QueryString.AllKeys.Contains("url") && Request.QueryString["url"] != null)
|
||||
if (Request.QueryString.AllKeys.Contains("url") == false || Request.QueryString["url"] == null)
|
||||
return;
|
||||
|
||||
var url = Request.QueryString["url"];
|
||||
if (string.IsNullOrWhiteSpace(url) || url.StartsWith("/"))
|
||||
return;
|
||||
|
||||
if (Uri.TryCreate(url, UriKind.Absolute, out var requestUri) == false)
|
||||
return;
|
||||
|
||||
var feedProxyXml = XmlHelper.OpenAsXmlDocument(IOHelper.MapPath(SystemFiles.FeedProxyConfig));
|
||||
if (feedProxyXml?.SelectSingleNode($"//allow[@host = '{requestUri.Host}']") != null && requestUri.Port == 80)
|
||||
{
|
||||
var url = Request.QueryString["url"];
|
||||
if (!string.IsNullOrWhiteSpace(url) && !url.StartsWith("/"))
|
||||
if (_httpClient == null)
|
||||
_httpClient = new HttpClient();
|
||||
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
|
||||
{
|
||||
Uri requestUri;
|
||||
if (Uri.TryCreate(url, UriKind.Absolute, out requestUri))
|
||||
{
|
||||
var feedProxyXml = xmlHelper.OpenAsXmlDocument(IOHelper.MapPath(SystemFiles.FeedProxyConfig));
|
||||
if (feedProxyXml != null
|
||||
&& feedProxyXml.SelectSingleNode(string.Concat("//allow[@host = '", requestUri.Host, "']")) != null
|
||||
&& requestUri.Port == 80)
|
||||
{
|
||||
if (_webClient == null)
|
||||
_webClient = new WebClient();
|
||||
|
||||
var response = _webClient.DownloadString(requestUri);
|
||||
var response = _httpClient.SendAsync(request).Result;
|
||||
var result = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (string.IsNullOrEmpty(response) == false)
|
||||
{
|
||||
Response.Clear();
|
||||
Response.ContentType = Request.CleanForXss("type") ?? MediaTypeNames.Text.Xml;
|
||||
Response.Write(response);
|
||||
}
|
||||
if (string.IsNullOrEmpty(result))
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Debug<FeedProxy>(string.Format("Access to unallowed feedproxy attempted: {0}", requestUri));
|
||||
}
|
||||
}
|
||||
Response.Clear();
|
||||
Response.ContentType = Request.CleanForXss("type") ?? MediaTypeNames.Text.Xml;
|
||||
Response.Write(result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Debug<FeedProxy>($"Access to unallowed feedproxy attempted: {requestUri}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user