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">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<ImplicitUsings>false</ImplicitUsings>
|
||||||
<ImplicitUsings>false</ImplicitUsings>
|
<Configurations>Debug</Configurations>
|
||||||
<Nullable>enable</Nullable>
|
<RootNamespace>Uwaa.HTTP.Example</RootNamespace>
|
||||||
<Configurations>Debug</Configurations>
|
<AssemblyName>Uwaa.HTTP.Example</AssemblyName>
|
||||||
<RootNamespace>Uwaa.HTTP.Example</RootNamespace>
|
</PropertyGroup>
|
||||||
<AssemblyName>Uwaa.HTTP.Example</AssemblyName>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<Import Project="../Common.targets"/>
|
||||||
<ProjectReference Include="..\HTTP\HTTP.csproj" />
|
|
||||||
|
|
||||||
<None Update="certs\*">
|
<ItemGroup>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<ProjectReference Include="..\HTTP\HTTP.csproj" />
|
||||||
</None>
|
|
||||||
<None Update="www-static\**\*">
|
<None Update="certs\*">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
<None Update="www-static\**\*">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<RootNamespace>Uwaa.HTTP</RootNamespace>
|
||||||
<Nullable>enable</Nullable>
|
<AssemblyName>Uwaa.HTTP</AssemblyName>
|
||||||
<RootNamespace>Uwaa.HTTP</RootNamespace>
|
</PropertyGroup>
|
||||||
<AssemblyName>Uwaa.HTTP</AssemblyName>
|
|
||||||
</PropertyGroup>
|
<Import Project="../Common.targets"/>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class HttpResponse
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Fields.ContentLength = null;
|
Fields.ContentLength = 0;
|
||||||
Fields.ContentType = null;
|
Fields.ContentType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,11 @@ public sealed class HttpServer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<HttpRequest, HttpResponse>? OnResponse;
|
public event Action<HttpRequest, HttpResponse>? OnResponse;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a request causes an exception.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<IPEndPoint, Exception>? OnException;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum time the socket may be inactive before it is presumed dead and closed.
|
/// The maximum time the socket may be inactive before it is presumed dead and closed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -179,12 +184,12 @@ public sealed class HttpServer
|
||||||
await new HttpResponse(400, e.Message).WriteTo(httpStream).WaitAsync(Timeout);
|
await new HttpResponse(400, e.Message).WriteTo(httpStream).WaitAsync(Timeout);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
break;
|
throw;
|
||||||
}
|
}
|
||||||
catch (TimeoutException)
|
catch (TimeoutException)
|
||||||
{
|
{
|
||||||
//Timeout
|
//Timeout
|
||||||
break;
|
throw;
|
||||||
}
|
}
|
||||||
catch (IOException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
|
@ -203,10 +208,11 @@ public sealed class HttpServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
//Swallow exceptions to prevent the server from crashing.
|
//Swallow exceptions to prevent the server from crashing.
|
||||||
//When debugging, use a debugger to break on exceptions.
|
//When debugging, use a debugger to break on exceptions.
|
||||||
|
OnException?.Invoke(endpoint, e);
|
||||||
}
|
}
|
||||||
finally
|
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;
|
var pool = ArrayPool<byte>.Shared;
|
||||||
byte[] closeBuf = pool.Rent(2);
|
byte[] closeBuf = pool.Rent(2);
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<RootNamespace>Uwaa.PNG</RootNamespace>
|
||||||
<Nullable>enable</Nullable>
|
<AssemblyName>Uwaa.PNG</AssemblyName>
|
||||||
<RootNamespace>Uwaa.PNG</RootNamespace>
|
</PropertyGroup>
|
||||||
</PropertyGroup>
|
|
||||||
|
<Import Project="../Common.targets"/>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<RootNamespace>Uwaa.Pleroma.Test</RootNamespace>
|
||||||
<Nullable>enable</Nullable>
|
<AssemblyName>Uwaa.Pleroma.Test</AssemblyName>
|
||||||
<RootNamespace>Uwaa.Pleroma.Test</RootNamespace>
|
</PropertyGroup>
|
||||||
<AssemblyName>Uwaa.Pleroma.Test</AssemblyName>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<Import Project="../Common.targets"/>
|
||||||
<ProjectReference Include="..\Pleroma\Pleroma.csproj" />
|
|
||||||
</ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Pleroma\Pleroma.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<RootNamespace>Uwaa.Pleroma</RootNamespace>
|
||||||
<Nullable>enable</Nullable>
|
<AssemblyName>Uwaa.Pleroma</AssemblyName>
|
||||||
<RootNamespace>Uwaa.Pleroma</RootNamespace>
|
</PropertyGroup>
|
||||||
<AssemblyName>Uwaa.Pleroma</AssemblyName>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<Import Project="../Common.targets"/>
|
||||||
<ProjectReference Include="..\HTTP\HTTP.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="System" />
|
<ProjectReference Include="..\HTTP\HTTP.csproj" />
|
||||||
<Using Include="System.Collections.Generic" />
|
</ItemGroup>
|
||||||
<Using Include="System.IO" />
|
|
||||||
<Using Include="System.Linq" />
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<Using Include="System" />
|
||||||
|
<Using Include="System.Collections.Generic" />
|
||||||
|
<Using Include="System.IO" />
|
||||||
|
<Using Include="System.Linq" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in a new issue