Skip to content

Commit a44ff1a

Browse files
Merge pull request #3 from ShawnLaMountain/main
Now supporting .Net Standard v1.1 - v2.1
2 parents c1dd0c3 + b71d9da commit a44ff1a

File tree

6 files changed

+31
-13
lines changed

6 files changed

+31
-13
lines changed

.github/workflows/CD.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ env:
2424
jobs:
2525
pack:
2626

27-
runs-on: [windows-latest]
27+
runs-on: [windows-2019]
2828

2929
steps:
3030
- name: Checkout

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
jobs:
1515
build:
1616

17-
runs-on: [windows-latest]
17+
runs-on: [windows-2019]
1818

1919
steps:
2020
- name: Checkout

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![CD](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.HttpClientService/actions/workflows/CD.yml/badge.svg)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.HttpClientService/actions/workflows/CD.yml)
44
[![Nuget](https://img.shields.io/nuget/v/ThunderDesign.Net-PCL.HttpClientService)](https://www.nuget.org/packages/ThunderDesign.Net-PCL.HttpClientService)
55
[![License](https://img.shields.io/github/license/ThunderDesign/ThunderDesign.Net-PCL.HttpClientService)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.HttpClientService/blob/main/LICENSE)
6-
[![Net](https://img.shields.io/badge/.net%20standard-2.0-blue)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.HttpClientService/blob/main/README.md)
6+
[![Net](https://img.shields.io/badge/.net%20standard-v1.1%20--%20v2.1-blue)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.HttpClientService/blob/main/README.md)
77

88
A wrapper around 'System.Net.Http.HttpClient' enhancing AutoRedirect and Cookies. Can be used in all application types.
99

src/ThunderDesign.Net-PCL.HttpClientService/Extentions/CookieContainerExtention.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ static public void SetCookies(this CookieContainer cookieContainer, HttpHeaders
2020
foreach (var value in header.Value)
2121
{
2222
var cookieCollection = ParseCookieString(value, defaultDomain);
23-
23+
#if NETSTANDARD2_0 || NETSTANDARD2_1
2424
cookieContainer.Add(cookieCollection);
25+
#else
26+
cookieContainer.Add(new Uri(defaultDomain), cookieCollection);
27+
#endif
2528
handler?.Invoke(cookieContainer, new CookieContainerChangedEventArgs(cookieCollection));
2629
}
2730
}
@@ -102,6 +105,6 @@ static private CookieCollection ParseCookieString(string cookieString, string de
102105
}
103106
return cookieCollection;
104107
}
105-
#endregion
108+
#endregion
106109
}
107110
}

src/ThunderDesign.Net-PCL.HttpClientService/Http/HttpClientAutoRedirect.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public HttpClientAutoRedirect(HttpMessageHandler handler, bool disposeHandler) :
4949
if (httpClientHandler.AllowAutoRedirect)
5050
httpClientHandler.AllowAutoRedirect = false;
5151
}
52+
#if NETSTANDARD2_0 || NETSTANDARD2_1
5253
//using reflection to read property values
5354
else
5455
{
@@ -69,6 +70,7 @@ public HttpClientAutoRedirect(HttpMessageHandler handler, bool disposeHandler) :
6970
//need to turn off AllowAutoRedirect since we are using our own
7071
handler.GetType().GetProperty(nameof(ICustomHttpMessageHandler.AllowAutoRedirect)).SetValue(handler, false);
7172
}
73+
#endif
7274
}
7375
#endregion
7476

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<RootNamespace>ThunderDesign.Net_PCL.HttpClientService</RootNamespace>
6-
</PropertyGroup>
7-
8-
<ItemGroup>
9-
<PackageReference Include="ThunderDesign.Net-PCL.Threading" Version="1.0.5" />
10-
</ItemGroup>
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard1.1;netstandard2.0;net461</TargetFrameworks>
5+
<RootNamespace>ThunderDesign.Net_PCL.HttpClientService</RootNamespace>
6+
<PackageReadmeFile>README.md</PackageReadmeFile>
7+
</PropertyGroup>
8+
9+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
10+
<DefineConstants>NETSTANDARD1_4</DefineConstants>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<None Include="..\..\README.md">
15+
<Pack>True</Pack>
16+
<PackagePath>\</PackagePath>
17+
</None>
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<PackageReference Include="System.Net.Http" Version="4.3.4" />
22+
<PackageReference Include="ThunderDesign.Net-PCL.Threading" Version="1.0.6" />
23+
</ItemGroup>
1124

1225
</Project>

0 commit comments

Comments
 (0)