Skip to content

Commit

Permalink
Merge pull request #8 from sisk-http/0.15
Browse files Browse the repository at this point in the history
fixes from 0.16
  • Loading branch information
CypherPotato authored Oct 30, 2023
2 parents 47a2152 + d905e41 commit 6348332
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Http/HttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ public object SendTo(RouterCallback otherCallback)
/// </type>
public HttpResponse Close()
{
return new HttpResponse(HttpResponse.HTTPRESPONSE_SERVER_CLOSE);
return new HttpResponse(HttpResponse.HTTPRESPONSE_SERVER_REFUSE);
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Http/HttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace Sisk.Core.Http
public sealed class HttpResponse : CookieHelper
{
internal const byte HTTPRESPONSE_EMPTY = 2;
internal const byte HTTPRESPONSE_SERVER_CLOSE = 4;
internal const byte HTTPRESPONSE_SERVER_REFUSE = 4;
internal const byte HTTPRESPONSE_SERVER_CLOSE = 6;
internal const byte HTTPRESPONSE_CLIENT_CLOSE = 32;
internal const byte HTTPRESPONSE_ERROR = 8;
internal int CalculedLength = 0;
Expand Down
9 changes: 8 additions & 1 deletion src/Http/HttpServer__Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ private void ListenerCallback(IAsyncResult result)
baseResponse.StatusCode = (int)response.Status;
goto finishSending;
}
else if (response?.internalStatus == HttpResponse.HTTPRESPONSE_SERVER_REFUSE)
{
executionResult.Status = HttpServerExecutionStatus.ConnectionClosed;
baseResponse.Abort();
goto finishSending;
}

byte[] responseBytes = response!.Content?.ReadAsByteArrayAsync().Result ?? new byte[] { };

Expand Down Expand Up @@ -306,7 +312,8 @@ private void ListenerCallback(IAsyncResult result)
executionResult.ResponseSize = outcomingSize;
executionResult.Response = response;

executionResult.Status = HttpServerExecutionStatus.Executed;
if (executionResult.Status == HttpServerExecutionStatus.NoResponse && response?.internalStatus != HttpResponse.HTTPRESPONSE_EMPTY)
executionResult.Status = HttpServerExecutionStatus.Executed;

sw.Stop();
baseResponse.Close();
Expand Down
6 changes: 3 additions & 3 deletions src/Sisk.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<RepositoryType>git</RepositoryType>
<PackageTags>http-server,http,web framework,event sources,web sockets</PackageTags>

<AssemblyVersion>0.15.1.0</AssemblyVersion>
<FileVersion>0.15.1.0</FileVersion>
<Version>0.15.1.0</Version>
<AssemblyVersion>0.15.2.0</AssemblyVersion>
<FileVersion>0.15.2.0</FileVersion>
<Version>0.15.2.0</Version>

<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<SignAssembly>False</SignAssembly>
Expand Down

0 comments on commit 6348332

Please sign in to comment.