SVN-Revision: r942
This commit is contained in:
tdx
2025-08-11 08:32:32 +00:00
parent d6bf22ef7c
commit 02379d3c01
+59 -2
View File
@@ -1,9 +1,12 @@
using System;
using Lskj.Web.Core.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace Lskj.Util
{
@@ -141,4 +144,58 @@ namespace Lskj.Util
{
foreach (var item in headerDic)
{
if (item.Key.Equals("Content-Type"))
{
httpWebRequest.ContentType = item.Value;
}
else
{
httpWebRequest.Headers.Add(item.Key, item.Value);
}
}
}
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream responseStream = httpWebResponse.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
result = streamReader.ReadToEnd();
streamReader.Close();
responseStream.Close();
return httpWebResponse;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
result = ex.Message;
return httpWebResponse;
}
}
/// <summary>
/// url转换
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static string ToEnUrl(string url)
{
string[] urlParams = url.Split('?');
string enKey = "encrypt", enVal = "";
bool hasEn = false;
if (urlParams.Length > 1)
{
string[] queryParams = urlParams[1].Split('&');
List<string> qpLS = new List<string>();
Hashtable pms = new Hashtable();
hasEn = queryParams.Any(str => str.Trim().StartsWith(enKey, StringComparison.OrdinalIgnoreCase));
foreach (string q in queryParams)
{
string[] eqParams = q.Split('=');
if (eqParams.Length > 1)
{
if (hasEn && eqParams[0].ToLower() == enKey)
{
enVal = eqParams[1];
continue;
}
if (hasEn || eqParams[0].ToLower() == "username" || eqParams[0].ToLower() == "password")
{
pms.Add(eqParams[0],