From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 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