Add Wox.CrashReporter

This commit is contained in:
qianlifeng
2015-01-11 21:52:30 +08:00
parent f20b4d570e
commit 5be6511529
33 changed files with 770 additions and 342 deletions

View File

@@ -53,6 +53,60 @@ namespace Wox.Infrastructure.Http
}
catch (Exception e)
{
Logger.Log.Error(e);
return string.Empty;
}
return string.Empty;
}
public static string Post(string url, string jsonData, IHttpProxy proxy)
{
if (string.IsNullOrEmpty(url)) return string.Empty;
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "text/json";
request.Timeout = 10 * 1000;
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)
{
Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
};
}
}
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(jsonData);
streamWriter.Flush();
streamWriter.Close();
}
try
{
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
if (response != null)
{
Stream stream = response.GetResponseStream();
if (stream != null)
{
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")))
{
return reader.ReadToEnd();
}
}
}
}
catch (Exception e)
{
Logger.Log.Error(e);
return string.Empty;
}