Compare commits
4 commits
9aa8a41389
...
c675cd221e
Author | SHA1 | Date | |
---|---|---|---|
|
c675cd221e | ||
|
210c8de1ed | ||
|
de1f3f756a | ||
|
48bd35d20b |
9 changed files with 80 additions and 63 deletions
10
Common.targets
Normal file
10
Common.targets
Normal file
|
@ -0,0 +1,10 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -1,22 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>false</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Configurations>Debug</Configurations>
|
||||
<RootNamespace>Uwaa.HTTP.Example</RootNamespace>
|
||||
<AssemblyName>Uwaa.HTTP.Example</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<ImplicitUsings>false</ImplicitUsings>
|
||||
<Configurations>Debug</Configurations>
|
||||
<RootNamespace>Uwaa.HTTP.Example</RootNamespace>
|
||||
<AssemblyName>Uwaa.HTTP.Example</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HTTP\HTTP.csproj" />
|
||||
<Import Project="../Common.targets"/>
|
||||
|
||||
<None Update="certs\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="www-static\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HTTP\HTTP.csproj" />
|
||||
|
||||
<None Update="certs\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="www-static\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Uwaa.HTTP</RootNamespace>
|
||||
<AssemblyName>Uwaa.HTTP</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Uwaa.HTTP</RootNamespace>
|
||||
<AssemblyName>Uwaa.HTTP</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="../Common.targets"/>
|
||||
</Project>
|
||||
|
|
|
@ -97,7 +97,7 @@ public class HttpResponse
|
|||
}
|
||||
else
|
||||
{
|
||||
Fields.ContentLength = null;
|
||||
Fields.ContentLength = 0;
|
||||
Fields.ContentType = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,11 @@ public sealed class HttpServer
|
|||
/// </summary>
|
||||
public event Action<HttpRequest, HttpResponse>? OnResponse;
|
||||
|
||||
/// <summary>
|
||||
/// Called when a request causes an exception.
|
||||
/// </summary>
|
||||
public event Action<IPEndPoint, Exception>? OnException;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum time the socket may be inactive before it is presumed dead and closed.
|
||||
/// </summary>
|
||||
|
@ -179,12 +184,12 @@ public sealed class HttpServer
|
|||
await new HttpResponse(400, e.Message).WriteTo(httpStream).WaitAsync(Timeout);
|
||||
}
|
||||
catch { }
|
||||
break;
|
||||
throw;
|
||||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
//Timeout
|
||||
break;
|
||||
throw;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
@ -203,10 +208,11 @@ public sealed class HttpServer
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
//Swallow exceptions to prevent the server from crashing.
|
||||
//When debugging, use a debugger to break on exceptions.
|
||||
OnException?.Invoke(endpoint, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -250,7 +250,7 @@ public class Websocket
|
|||
}
|
||||
}
|
||||
|
||||
internal async void Close(CloseStatus status = CloseStatus.NormalClosure)
|
||||
internal async Task Close(CloseStatus status = CloseStatus.NormalClosure)
|
||||
{
|
||||
var pool = ArrayPool<byte>.Shared;
|
||||
byte[] closeBuf = pool.Rent(2);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Uwaa.PNG</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Uwaa.PNG</RootNamespace>
|
||||
<AssemblyName>Uwaa.PNG</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="../Common.targets"/>
|
||||
</Project>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Uwaa.Pleroma.Test</RootNamespace>
|
||||
<AssemblyName>Uwaa.Pleroma.Test</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<RootNamespace>Uwaa.Pleroma.Test</RootNamespace>
|
||||
<AssemblyName>Uwaa.Pleroma.Test</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pleroma\Pleroma.csproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="../Common.targets"/>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pleroma\Pleroma.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Uwaa.Pleroma</RootNamespace>
|
||||
<AssemblyName>Uwaa.Pleroma</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<RootNamespace>Uwaa.Pleroma</RootNamespace>
|
||||
<AssemblyName>Uwaa.Pleroma</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HTTP\HTTP.csproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="../Common.targets"/>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="System" />
|
||||
<Using Include="System.Collections.Generic" />
|
||||
<Using Include="System.IO" />
|
||||
<Using Include="System.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HTTP\HTTP.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="System" />
|
||||
<Using Include="System.Collections.Generic" />
|
||||
<Using Include="System.IO" />
|
||||
<Using Include="System.Linq" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in a new issue