test
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -16,10 +17,12 @@ namespace WMS.Web.Core.Help
|
||||
public class HttpClientHelp
|
||||
{
|
||||
private HttpOptions _options;
|
||||
private ILogger<HttpClientHelp> _logger;
|
||||
|
||||
public HttpClientHelp(IOptions<HttpOptions> options)
|
||||
public HttpClientHelp(IOptions<HttpOptions> options, ILogger<HttpClientHelp> logger)
|
||||
{
|
||||
this._options = options?.Value;
|
||||
this._logger = logger;
|
||||
}
|
||||
public string PostHttp(string url, JsonObject reqData, bool isHaveCookie = false, string cookieValue = "", string appSecret = "")
|
||||
{
|
||||
@@ -84,6 +87,8 @@ namespace WMS.Web.Core.Help
|
||||
|
||||
public string PostHttp(string url, LoginAuthorizeRequest reqData)
|
||||
{
|
||||
_logger.LogInformation($"HttpPost->11111111111111111");
|
||||
|
||||
var str = string.Format("client_id={0}&client_secret={1}&grant_type={2}&username={3}&password={4}&scope={5}",
|
||||
reqData.ClientId, reqData.ClientSecret, reqData.GrantType, reqData.UserName, reqData.Password,reqData.Scope);
|
||||
ASCIIEncoding encoding = new ASCIIEncoding();
|
||||
@@ -96,17 +101,19 @@ namespace WMS.Web.Core.Help
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.BaseAddress = new Uri(url);
|
||||
httpClient.Timeout = new TimeSpan(0, 0, 10);
|
||||
|
||||
_logger.LogInformation($"HttpPost-2>"+ str);
|
||||
HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var resData = response.Content.ReadAsStringAsync().Result;
|
||||
_logger.LogInformation($"HttpPost-3>" + resData);
|
||||
return resData;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var resData = response.Content.ReadAsStringAsync().Result;
|
||||
_logger.LogInformation($"HttpPost-4>" + resData);
|
||||
return resData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user