From d66d362ee6d76f02331e56df1fdec1c2114c9f3e Mon Sep 17 00:00:00 2001
From: zxx <Zxx@HanInfo>
Date: 星期三, 16 七月 2025 17:31:41 +0800
Subject: [PATCH] 1

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.XiaoMi/util/HttpHelper.cs |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.XiaoMi/util/HttpHelper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.XiaoMi/util/HttpHelper.cs
index 05b5941..47b6c9d 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.XiaoMi/util/HttpHelper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.XiaoMi/util/HttpHelper.cs
@@ -129,6 +129,46 @@
             }
 
         }
+        public string Put(string url, string putData, string contentType = "application/json", string sessionId = "")
+        {
+            Console.WriteLine(url);
+            WebRequest request = WebRequest.Create(url);
+            request.Method = "PUT";
+            byte[] byteArray = Encoding.UTF8.GetBytes(putData);
+            request.ContentType = contentType;
+            request.ContentLength = byteArray.Length;
+            request.Timeout = 3000;
+            if (sessionId != "")
+            {
+                request.Headers.Set("ASP.NET_SessionId", sessionId);
+            }
+            StreamReader reader = null;
+            Stream stream = null;
+            WebResponse rsp = null;
+            try
+            {
+                stream = request.GetRequestStream();
+                stream.Write(byteArray, 0, byteArray.Length);
+                stream.Close();
+                rsp = request.GetResponse();
+                stream = rsp.GetResponseStream();
+                reader = new StreamReader(stream);
+                return reader.ReadToEnd();
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine($"{url} err={ex.Message}");
+                return "";
+            }
+            finally
+            {
+                // 閲婃斁璧勬簮
+                if (reader != null) reader.Close();
+                if (stream != null) stream.Close();
+                if (rsp != null) rsp.Close();
+            }
+
+        }
 
 
         public string Post(string url, Dictionary<string, string> dic) {

--
Gitblit v1.9.1