Selaa lähdekoodia

fix HttpClient Serialize issue

Lith 11 kuukautta sitten
vanhempi
commit
cdb074a60d

+ 9 - 1
dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Net/HttpClient.cs

@@ -47,6 +47,9 @@ namespace Vit.Core.Util.Net
                     case byte[] bytes:
                         httpRequest.Content = new ByteArrayContent(bytes);
                         break;
+                    case string str:
+                        httpRequest.Content = new System.Net.Http.StringContent(str);
+                        break;
                     case HttpContent httpContent:
                         httpRequest.Content = httpContent;
                         break;
@@ -93,11 +96,16 @@ namespace Vit.Core.Util.Net
 
             //if (response.IsSuccessStatusCode)
             {
-                if (typeof(byte[]).IsAssignableFrom(typeof(T)))
+                if (typeof(T) == typeof(byte[]))
                 {
                     object data = await response.Content.ReadAsByteArrayAsync();
                     httpResponse.data = (T)data;
                 }
+                else if (typeof(T) == typeof(string))
+                {
+                    object data = await response.Content.ReadAsStringAsync();
+                    httpResponse.data = (T)data;
+                }
                 else
                 {
                     string data = await response.Content.ReadAsStringAsync();

+ 1 - 1
dotnet/Library/Vit/Vit.Core/Vit.Core/Vit.Core.csproj

@@ -6,7 +6,7 @@
 
     <PropertyGroup>
         <TargetFramework>netstandard2.0</TargetFramework>
-        <Version>2.1.21</Version>
+        <Version>2.1.22-temp</Version>
     </PropertyGroup>
 
     <PropertyGroup>

+ 1 - 1
dotnet/Library/Vit/Vit.Net.Http.FormFile/Vit.Net.Http.FormFile.csproj

@@ -6,7 +6,7 @@
 
     <PropertyGroup>
         <TargetFramework>netstandard2.0</TargetFramework>
-        <Version>2.1.21</Version>
+        <Version>2.1.22-temp</Version>
     </PropertyGroup>
 
     <PropertyGroup>

+ 1 - 1
dotnet/Library/Vit/Vit.WebHost/Vit.WebHost.csproj

@@ -6,7 +6,7 @@
 
     <PropertyGroup>
         <TargetFramework>netstandard2.0</TargetFramework>
-        <Version>2.1.21</Version>
+        <Version>2.1.22-temp</Version>
     </PropertyGroup>
 
     <PropertyGroup>