|
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|
using System.Net.Http;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using TEAMModelOS.SDK.Context.Configuration;
|
|
|
|
+using TEAMModelOS.SDK.Context.Constant.Common;
|
|
using HttpClientSpace = System.Net.Http;
|
|
using HttpClientSpace = System.Net.Http;
|
|
|
|
|
|
namespace TEAMModelOS.SDK.Extension.HttpClient.Implements
|
|
namespace TEAMModelOS.SDK.Extension.HttpClient.Implements
|
|
@@ -10,11 +12,12 @@ namespace TEAMModelOS.SDK.Extension.HttpClient.Implements
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 需要调整的 https://blog.yowko.com/httpclientfactory-dotnet-core-dotnet-framework/
|
|
/// 需要调整的 https://blog.yowko.com/httpclientfactory-dotnet-core-dotnet-framework/
|
|
/// </summary>
|
|
/// </summary>
|
|
- public class HttpClientService
|
|
|
|
|
|
+ public class HttpClientSendCloud
|
|
{
|
|
{
|
|
HttpClientSpace.HttpClient client { get; }
|
|
HttpClientSpace.HttpClient client { get; }
|
|
- public HttpClientService(HttpClientSpace.HttpClient _client)
|
|
|
|
|
|
+ public HttpClientSendCloud(HttpClientSpace.HttpClient _client)
|
|
{
|
|
{
|
|
|
|
+ // _client.DefaultRequestHeaders.Add(Constants.AUTHORIZATION, BaseConfigModel.Configuration["SmsSendCloud:UserInfoKey"]);
|
|
client = _client;
|
|
client = _client;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -28,13 +31,13 @@ namespace TEAMModelOS.SDK.Extension.HttpClient.Implements
|
|
public string HttpGet(string url, Dictionary<string, string> headers = null, int timeout = 0)
|
|
public string HttpGet(string url, Dictionary<string, string> headers = null, int timeout = 0)
|
|
{
|
|
{
|
|
|
|
|
|
- if (headers != null)
|
|
|
|
- {
|
|
|
|
- foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
- {
|
|
|
|
- client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //if (headers != null)
|
|
|
|
+ //{
|
|
|
|
+ // foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
+ // {
|
|
|
|
+ // client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
if (timeout > 0)
|
|
if (timeout > 0)
|
|
{
|
|
{
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
@@ -52,13 +55,13 @@ namespace TEAMModelOS.SDK.Extension.HttpClient.Implements
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public async Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null, int timeout = 0)
|
|
public async Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null, int timeout = 0)
|
|
{
|
|
{
|
|
- if (headers != null)
|
|
|
|
- {
|
|
|
|
- foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
- {
|
|
|
|
- client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //if (headers != null)
|
|
|
|
+ //{
|
|
|
|
+ // foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
+ // {
|
|
|
|
+ // client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
if (timeout > 0)
|
|
if (timeout > 0)
|
|
{
|
|
{
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
@@ -80,13 +83,13 @@ namespace TEAMModelOS.SDK.Extension.HttpClient.Implements
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public string HttpPost(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
|
|
public string HttpPost(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
|
|
{
|
|
{
|
|
- if (headers != null)
|
|
|
|
- {
|
|
|
|
- foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
- {
|
|
|
|
- client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //if (headers != null)
|
|
|
|
+ //{
|
|
|
|
+ // foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
+ // {
|
|
|
|
+ // client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
if (timeout > 0)
|
|
if (timeout > 0)
|
|
{
|
|
{
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
@@ -114,13 +117,13 @@ namespace TEAMModelOS.SDK.Extension.HttpClient.Implements
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public async Task<string> HttpPostAsync(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
|
|
public async Task<string> HttpPostAsync(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
|
|
{
|
|
{
|
|
- if (headers != null)
|
|
|
|
- {
|
|
|
|
- foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
- {
|
|
|
|
- client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //if (headers != null)
|
|
|
|
+ //{
|
|
|
|
+ // foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
+ // {
|
|
|
|
+ // client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
if (timeout > 0)
|
|
if (timeout > 0)
|
|
{
|
|
{
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
@@ -148,13 +151,13 @@ namespace TEAMModelOS.SDK.Extension.HttpClient.Implements
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public async Task<string> HttpPostAsync(string url, List<KeyValuePair<string, string>> postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
|
|
public async Task<string> HttpPostAsync(string url, List<KeyValuePair<string, string>> postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
|
|
{
|
|
{
|
|
- if (headers != null)
|
|
|
|
- {
|
|
|
|
- foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
- {
|
|
|
|
- client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //if (headers != null)
|
|
|
|
+ //{
|
|
|
|
+ // foreach (KeyValuePair<string, string> header in headers)
|
|
|
|
+ // {
|
|
|
|
+ // client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
if (timeout > 0)
|
|
if (timeout > 0)
|
|
{
|
|
{
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|
|
client.Timeout = new TimeSpan(0, 0, timeout);
|