From 57ee144531c49f73fcf98130d5113a43d1311487 Mon Sep 17 00:00:00 2001 From: TheSuunny Date: Fri, 17 Jun 2022 14:01:09 +0300 Subject: [PATCH] feat: update nuget --- FodyWeavers.xml | 3 ++- FodyWeavers.xsd | 30 ++++++++++++++++++++++++++++++ HttpClient.cs | 16 ++++++++++------ Proxy/ProxyClient.cs | 18 +++++++++++------- README.md | 10 +++++----- Yove.Http.csproj | 12 ++++-------- 6 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 FodyWeavers.xsd diff --git a/FodyWeavers.xml b/FodyWeavers.xml index 68788ac..e706069 100644 --- a/FodyWeavers.xml +++ b/FodyWeavers.xml @@ -1,3 +1,4 @@ - + + \ No newline at end of file diff --git a/FodyWeavers.xsd b/FodyWeavers.xsd new file mode 100644 index 0000000..3f3946e --- /dev/null +++ b/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/HttpClient.cs b/HttpClient.cs index 6859bad..4635b30 100644 --- a/HttpClient.cs +++ b/HttpClient.cs @@ -465,19 +465,23 @@ private async Task CreateConnection(string host, int port) using CancellationTokenSource cancellationToken = new(TimeSpan.FromMilliseconds(TimeOut)); - ValueTask connectionTask = tcpClient.ConnectAsync(host, port, cancellationToken.Token); - try { - await connectionTask; +#if NETSTANDARD2_1 || NETCOREAPP3_1 + tcpClient.ConnectAsync(host, port).Wait(cancellationToken.Token); +#elif NET5_0_OR_GREATER + await tcpClient.ConnectAsync(host, port, cancellationToken.Token); +#endif + + if (!tcpClient.Connected) + throw new(); } catch { - throw new HttpRequestException($"Failed Connection to Address: {Address.AbsoluteUri}"); - } + tcpClient.Dispose(); - if (!tcpClient.Connected) throw new HttpRequestException($"Failed Connection to Address: {Address.AbsoluteUri}"); + } return tcpClient; } diff --git a/Proxy/ProxyClient.cs b/Proxy/ProxyClient.cs index 16f9b0e..ee3efbc 100644 --- a/Proxy/ProxyClient.cs +++ b/Proxy/ProxyClient.cs @@ -61,19 +61,23 @@ internal async Task CreateConnection(string destinationHost, int dest using CancellationTokenSource cancellationToken = new(TimeSpan.FromMilliseconds(TimeOut)); - ValueTask connectionTask = tcpClient.ConnectAsync(Host, Port, cancellationToken.Token); - try { - await connectionTask; +#if NETSTANDARD2_1 || NETCOREAPP3_1 + tcpClient.ConnectAsync(Host, Port).Wait(cancellationToken.Token); +#elif NET5_0_OR_GREATER + await tcpClient.ConnectAsync(Host, Port, cancellationToken.Token); +#endif + + if (!tcpClient.Connected) + throw new(); } catch { - throw new HttpProxyException($"Failed Connection to proxy: {Host}:{Port}"); - } + tcpClient.Dispose(); - if (!tcpClient.Connected) - throw new HttpProxyException($"Failed Connection to proxy: {Host}:{Port}"); + throw new HttpRequestException($"Failed Connection to proxy: {Host}:{Port}"); + } NetworkStream networkStream = tcpClient.GetStream(); diff --git a/README.md b/README.md index 9ffdf47..0854d93 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ # Yove.Http | Http Client / Http Framework -[![NuGet version](https://badge.fury.io/nu/Yove.Http.svg)](https://badge.fury.io/nu/Yove.Http) -[![Downloads](https://img.shields.io/nuget/dt/Yove.Http.svg)](https://www.nuget.org/packages/Yove.Http) +[![NuGet version](https://badge.fury.io/nu/Yove.HttpClient.svg)](https://badge.fury.io/nu/Yove.HttpClient) +[![Downloads](https://img.shields.io/nuget/dt/Yove.HttpClient.svg)](https://www.nuget.org/packages/Yove.HttpClient) [![Target](https://img.shields.io/badge/.NET%20Standard-2.0-green.svg)](https://docs.microsoft.com/ru-ru/dotnet/standard/net-standard) -Nuget: https://www.nuget.org/packages/Yove.Http/ +Nuget: https://www.nuget.org/packages/Yove.HttpClient ``` -Install-Package Yove.Http +Install-Package Yove.HttpClient ``` ``` -dotnet add package Yove.Http +dotnet add package Yove.HttpClient ``` --- diff --git a/Yove.Http.csproj b/Yove.Http.csproj index 2faf9c1..521b170 100644 --- a/Yove.Http.csproj +++ b/Yove.Http.csproj @@ -1,19 +1,15 @@ - net6.0 + net6.0;net5.0;netstandard2.1;netcoreapp3.1 + 10 true true snupkg - true - - - Yove.HttpClient - 1.6.0 + 1.6.1 Sunny en-US, ru-RU Http Client for .Net | Http, Socks4, Socks5 client - net6.0 http; client; framework; .net core; .net; socks4; socks5; https; https://github.com/TheSuunny/Yove.Http https://github.com/TheSuunny/Yove.Http @@ -26,6 +22,6 @@ - + \ No newline at end of file