@@ -12,15 +12,15 @@ namespace SimApi.Helpers;
1212
1313public class SimApiHttpClient ( SimApiOptions ? apiOptions = null , ILogger < SimApiHttpClient > ? logger = null )
1414{
15- public virtual string Server { get ; init ; } = apiOptions ? . SimApiHttpClientOptions . Server ?? string . Empty ;
16- public virtual string AppId { get ; init ; } = apiOptions ? . SimApiHttpClientOptions . AppId ?? string . Empty ;
17- public virtual string AppKey { get ; init ; } = apiOptions ? . SimApiHttpClientOptions . AppKey ?? string . Empty ;
15+ public virtual string Server { get ; init ; } = apiOptions ? . SimApiHttpClientOptions . Server ?? string . Empty ;
16+ public virtual string AppId { get ; init ; } = apiOptions ? . SimApiHttpClientOptions . AppId ?? string . Empty ;
17+ public virtual string AppKey { get ; init ; } = apiOptions ? . SimApiHttpClientOptions . AppKey ?? string . Empty ;
1818
19- public virtual string SignName { get ; init ; } = "sign" ;
20- public virtual string TimestampName { get ; init ; } = "timestamp" ;
21- public virtual string NonceName { get ; init ; } = "nonce" ;
22- public virtual string ? AppIdName { get ; init ; } = "appId" ;
23- public virtual string [ ] SignFields { get ; init ; } = [ ] ;
19+ public virtual string SignName { get ; init ; } = "sign" ;
20+ public virtual string TimestampName { get ; init ; } = "timestamp" ;
21+ public virtual string NonceName { get ; init ; } = "nonce" ;
22+ public virtual string ? AppIdName { get ; init ; } = "appId" ;
23+ public virtual string [ ] SignFields { get ; init ; } = [ ] ;
2424
2525 /// <summary>
2626 /// 发起签名请求
@@ -106,6 +106,7 @@ public class SimApiHttpClient(SimApiOptions? apiOptions = null, ILogger<SimApiHt
106106 logger ? . LogDebug ( $ "[HTTPCLIENT请求] { url } \n { SimApiUtil . Json ( req ) } \n ") ;
107107 var resp = http . PostAsJsonAsync ( url , req ) . Result ;
108108 logger ? . LogDebug ( $ "[HTTPCLIENT响应] { resp . Content . ReadAsStringAsync ( ) . Result } \n ") ;
109+ SimApiError . ErrorWhenFalse ( resp . IsSuccessStatusCode , ( int ) resp . StatusCode , $ "HTTP ERROR: { resp . StatusCode } ") ;
109110 var res = resp . Content . ReadFromJsonAsync < SimApiBaseResponse < T > > ( ) . Result ;
110111 SimApiError . ErrorWhenNull ( res , 500 , "请求发生错误" ) ;
111112 SimApiError . ErrorWhen ( res . Code != 200 , res . Code , res . Message ) ;
0 commit comments