From dc0309e64f02227d8e1468b7326c07955f804612 Mon Sep 17 00:00:00 2001
From: chenqiyang <1406175257@qq.com>
Date: 星期三, 22 六月 2022 11:22:18 +0800
Subject: [PATCH] 修改引用路径
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlHttpLogic.cs | 89 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 89 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlHttpLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlHttpLogic.cs
new file mode 100644
index 0000000..217eedd
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlHttpLogic.cs
@@ -0,0 +1,89 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Net;
+using System.Text;
+
+namespace Shared.Phone.UserCenter
+{
+ /// <summary>
+ /// Http璁块棶閫昏緫
+ /// </summary>
+ public class HdlHttpLogic
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// Http璁块棶閫昏緫
+ /// </summary>
+ private static HdlHttpLogic m_Current = null;
+ /// <summary>
+ /// Http璁块棶閫昏緫
+ /// </summary>
+ public static HdlHttpLogic Current
+ {
+ get
+ {
+ if (m_Current == null)
+ {
+ m_Current = new HdlHttpLogic();
+ }
+ return m_Current;
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 绗笁鏂规帴鍙h闂甠____________________
+
+ /// <summary>
+ /// 绗笁鏂规帴鍙h闂�
+ /// </summary>
+ /// <param name="requestFullUrl">璇锋眰Url鐨勫畬鎴愯矾寰�</param>
+ /// <param name="contentType">text/html 鎴栬�� application/json</param>
+ /// <param name="requestMethod">POST 鎴栬�� GET 绛夌瓑</param>
+ /// <param name="timeout">瓒呮椂,榛樿5绉�</param>
+ /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns>
+ public byte[] RequestThridPartyHttps(string requestFullUrl, string contentType = "text/html", string requestMethod = "GET", int timeout = 5)
+ {
+ try
+ {
+ //鍒濆鍖栨柊鐨剋ebRequst
+ //1锛� 鍒涘缓httpWebRequest瀵硅薄
+ var webRequest = (HttpWebRequest)WebRequest.Create(new Uri(requestFullUrl));
+
+ //2锛� 鍒濆鍖朒ttpWebRequest瀵硅薄
+ webRequest.Method = requestMethod;
+ webRequest.Timeout = timeout * 1000;
+ //鍙栨秷浣跨敤浠g悊璁块棶
+ webRequest.Proxy = null;
+ webRequest.UseDefaultCredentials = false;
+ webRequest.ContentType = contentType;
+
+ //4锛� 璇诲彇鏈嶅姟鍣ㄧ殑杩斿洖淇℃伅
+ var response = (HttpWebResponse)webRequest.GetResponse();
+ using (var stream = response.GetResponseStream())
+ {
+ if (stream == null)
+ {
+ return null;
+ }
+ var ms = new System.IO.MemoryStream();
+ var bytes = new byte[1024];
+ var len = int.MaxValue;
+ while (stream.CanRead && 0 < len)
+ {
+ len = stream.Read(bytes, 0, bytes.Length);
+ ms.Write(bytes, 0, len);
+ }
+ return ms.ToArray();
+ }
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ #endregion
+ }
+}
--
Gitblit v1.8.0