NHttp.Core
1.1.2.201
See the version list below for details.
dotnet add package NHttp.Core --version 1.1.2.201
NuGet\Install-Package NHttp.Core -Version 1.1.2.201
<PackageReference Include="NHttp.Core" Version="1.1.2.201" />
<PackageVersion Include="NHttp.Core" Version="1.1.2.201" />
<PackageReference Include="NHttp.Core" />
paket add NHttp.Core --version 1.1.2.201
#r "nuget: NHttp.Core, 1.1.2.201"
#:package NHttp.Core@1.1.2.201
#addin nuget:?package=NHttp.Core&version=1.1.2.201
#tool nuget:?package=NHttp.Core&version=1.1.2.201
NHttp.Core
LGPL License.
Introduction
NHttp is a very lightweighted, simply asynchronous Web server which supports Http/Https(only http1.1) written in C# implemented in netstandard2.0, and is performance friendly. According to my crude benchmark(JMeter) on plain http api calls that return json texts with the same api implementation(no asp.net core mvc/webapi) on both Nhttp.core and Kestrel, Nttps outperforms more than double that of Kestrel.
Calls Resp% Resp.Time
Nhttp.Core(h1.1)
500 100% 40
1000 100% 1255
1500 100% 1863
Kestrel(h2)
500 100% 905
1000 100% 2691
1500 100% 3855
NHttp supports the following features:
Full request parsing similar to the ASP.net model;
High performance asynchronous request processing using TcpListener/TcpClient;
Complete query string parsing;
Complete form parsing (i.e. application/x-www-form-urlencoded);
Complete multi-part parsing including file upload (i.e. multipart/form-data);
Support for parsing and sending cookies.
Support Https protocol & SSL.
NHttp specifically does not support any kind of utilities producing output. It for example does not provide a StreamWriter or perform routing. Besides e.g. the Headers and Cookies collections, only the raw output stream is provided. The rest is up to you!
Usage
The following shows how to use NHttp:
using (var server = new HttpServer())
{
server.RequestReceived += (s, e) =>
{
using (var writer = new StreamWriter(e.Response.OutputStream))
{
writer.Write("Hello world!");
}
};
server.Start();
Process.Start(String.Format("http://{0}/", server.EndPoint));
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
Processing requests in NHttp is done in the RequestReceived event. There you have access to the request and response information the request. The example above creates a StreamReader to be able to write text to the response and outputs the same response for every request.
By default, NHttp listens to a random port. Use the following method to specify the port NHttp should listen on:
using (var server = new HttpServer())
{
// ...
server.EndPoint = new IPEndPoint(IPAddress.Loopback, 80);
server.Start();
// ...
}
This method can also be used to change the interface the HttpServer should be listening to.
Logging
This fork of NHttp references one of my other opensource projects - WMLogService for logging, which implements Common.Logging interfaces and can be configured to use 3rd party log modules which implement Common.Logging including popular Log4net. But i think they r just too heavy, and i think my own lighted-weighted log module works better, at least for my own use.
Bugs
Bugs should be reported through github at https://github.com/xiaoyuvax/NHttp.Core/issues.
License
NHttp is licensed under the LGPL 3.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Common.Logging.Core (>= 3.4.1)
-
net10.0
- Common.Logging.Core (>= 3.4.1)
-
net8.0
- Common.Logging.Core (>= 3.4.1)
-
net9.0
- Common.Logging.Core (>= 3.4.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NHttp.Core:
| Package | Downloads |
|---|---|
|
Wima.Web.Engine
Wima通用Web引擎库,支持Kestrel和超轻量级Nhttp(1.1+SSL) |
GitHub repositories
This package is not used by any popular GitHub repositories.