dc/Utilities/HttpUtils.cs
13118993771@163.com 5e9d0f1e2d EAP
2022-04-01 17:03:54 +08:00

76 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#region << >>
/*----------------------------------------------------------------
* 创建者13118
* 创建时间2022/3/17 14:52:03
* 版本V1.0.0
* 描述:
*
* ----------------------------------------------------------------
* 修改人:
* 时间:
* 修改说明:
*
* 版本V1.0.1
*----------------------------------------------------------------*/
#endregion << >>
using ARI.EAP.HOST.SRD;
using Glorysoft.SECS.EQP.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace ARI.EAP.HOST.Utilities
{
/// <summary>
/// HttpUtils 的摘要说明
/// 调用http接口工具类
/// </summary>
public static class HttpUtils
{
public static HttpWebResponse sentPOST(string url,string content)
{
HttpWebRequest postRequest=(HttpWebRequest)WebRequest.Create(url);
postRequest.Method = "POST";
postRequest.ContentType = Configuration.conf.httpConfiguration.contentType;
postRequest.Timeout = 10000;
try
{
using (StreamWriter dataStream = new StreamWriter(postRequest.GetRequestStream()))
{
dataStream.Write(content);
dataStream.Close();
}
HttpWebResponse response = (HttpWebResponse)postRequest.GetResponse();
return response;
}catch(Exception e)
{
LoggerService.SYSLogger.Error(e);
return null;
}
}
public static HttpWebResponse sentGET(string url,string param)
{
url = url + param;
HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(url);
getRequest.Method = "GET";
getRequest.ContentType = Configuration.conf.httpConfiguration.contentType;
try
{
HttpWebResponse response = (HttpWebResponse)getRequest.GetResponse();
return response;
}
catch (Exception e)
{
LoggerService.SYSLogger.Error(e);
return null;
}
}
}
}