This commit is contained in:
jackchenyang
2024-06-11 11:36:17 +08:00
parent ab9ea7b2e9
commit 7868671ddb
27 changed files with 103 additions and 1936 deletions
+13 -3
View File
@@ -116,7 +116,7 @@ namespace BLL.Common
const string post = "POST";
if (string.Equals(requestType, get, StringComparison.OrdinalIgnoreCase))
{
request = CreateGetHttpWebRequest(url);
request = CreateGetHttpWebRequest(url,token);
}
if (string.Equals(requestType, post, StringComparison.OrdinalIgnoreCase))
{
@@ -125,12 +125,22 @@ namespace BLL.Common
return request;
}
private static HttpWebRequest CreateGetHttpWebRequest(string url)
private static HttpWebRequest CreateGetHttpWebRequest(string url,string token)
{
var getRequest = HttpWebRequest.Create(url) as HttpWebRequest;
if (!string.IsNullOrEmpty(token))
{
getRequest.ContentType = "application/json";
getRequest.Headers.Add("token", token);
}
else
{
getRequest.ContentType = "text/html;charset=UTF-8";
}
getRequest.Method = "GET";
getRequest.Timeout = 5000;
getRequest.ContentType = "text/html;charset=UTF-8";
getRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
return getRequest;
}