mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
Add upgrade check.
This commit is contained in:
@@ -9,6 +9,8 @@ using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
//From:http://blog.csdn.net/zhoufoxcn/article/details/6404236
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public class HttpRequest
|
||||
@@ -16,6 +18,30 @@ namespace Wox.Infrastructure
|
||||
private static readonly string DefaultUserAgent = "Wox/" + Assembly.GetEntryAssembly().GetName().Version.ToString() + " (+https://github.com/qianlifeng/Wox)";
|
||||
|
||||
|
||||
public static HttpWebResponse CreateGetHttpResponse(string url, IHttpProxy proxy)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException("url");
|
||||
}
|
||||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
|
||||
{
|
||||
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
|
||||
{
|
||||
request.Proxy = new WebProxy(proxy.Server, proxy.Port);
|
||||
}
|
||||
else
|
||||
{
|
||||
request.Proxy = new WebProxy(proxy.Server, proxy.Port);
|
||||
request.Proxy.Credentials = new NetworkCredential(proxy.UserName, proxy.Password);
|
||||
}
|
||||
}
|
||||
request.Method = "GET";
|
||||
request.UserAgent = DefaultUserAgent;
|
||||
return request.GetResponse() as HttpWebResponse;
|
||||
}
|
||||
|
||||
public static HttpWebResponse CreateGetHttpResponse(string url, int? timeout, string userAgent, CookieCollection cookies)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
|
||||
Reference in New Issue
Block a user