-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
002f2b8
commit 970a91d
Showing
12 changed files
with
375 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Sisk managed HTTP listener | ||
|
||
This folder contains the code for the implementation of the Sisk HTTP/1.1 listener. It is a managed alternative to the [HttpListener](https://learn.microsoft.com/en-us/dotnet/api/system.net.httplistener?view=net-9.0) of .NET. This implementation exists because: | ||
|
||
- We do not know how long Microsoft will want to maintain HttpListener as a component of .NET. | ||
- It is not possible to use HttpListener with SSL natively, only with a reverse proxy or with IIS on Windows. | ||
- The implementation of HttpListener outside of Windows is awful, but stable. This implementation is an attempt to create something more performant, closer or better than Kestrel speeds. | ||
|
||
## How to use | ||
|
||
For now, this implementation does not even have a package or is used in Sisk.HttpServer, but it can be used with: | ||
|
||
```csharp | ||
static void Main ( string [] args ) { | ||
HttpHost host = new HttpHost ( 5555, HandleSession ); | ||
|
||
// optional properties to run SSL | ||
host.HttpsOptions = new HttpsOptions ( CertificateUtil.CreateTrustedDevelopmentCertificate () ); | ||
|
||
Console.WriteLine ( "server running at : http://localhost:5555/" ); | ||
|
||
host.Start (); | ||
Thread.Sleep ( -1 ); | ||
} | ||
|
||
public static void HandleSession ( HttpSession session ) { | ||
// handle the request here | ||
} | ||
``` | ||
|
||
## Implementation status | ||
|
||
This package is expected to supersede Sisk.SslProxy and deprecate it. | ||
|
||
The current status of the implementation is: | ||
|
||
| Resource | Status | Notes | | ||
| ------- | ------ | ----------- | | ||
| Base HTTP/1.1 Reader | Functional | | | ||
| HTTPS | Functional | | | ||
| Expect-100 header | Not implemented | There is already an implementation in Sisk.SslProxy. | | ||
| Chunked transfer-encoding | Not implemented | | | ||
| SSE/Response content streaming | Not implemented | | | ||
| Web Sockets | Not implemented | | | ||
|
||
Everything in this project is still super experimental and should never be used in production. | ||
|
||
## License | ||
|
||
The same as the Sisk project (MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// The Sisk Framework source code | ||
// Copyright (c) 2024- PROJECT PRINCIPIUM and all Sisk contributors | ||
// | ||
// The code below is licensed under the MIT license as | ||
// of the date of its publication, available at | ||
// | ||
// File name: HttpConnectionState.cs | ||
// Repository: https://github.com/sisk-http/core | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Sisk.ManagedHttpListener; | ||
|
||
internal enum HttpConnectionState { | ||
ConnectionClosed = 0, | ||
ConnectionClosedByStreamRead = 1, | ||
|
||
UnhandledException = 10, | ||
|
||
BadRequest = 20, | ||
|
||
ResponseWriteException = 30, | ||
} | ||
|
||
internal enum HttpRequestReadState { | ||
RequestRead = 0, | ||
StreamZero = 1, | ||
StreamError = 2 | ||
} |
Oops, something went wrong.