![]() |
VOOZH | about |
dotnet add package HttpMachine.PCL --version 5.0.1
NuGet\Install-Package HttpMachine.PCL -Version 5.0.1
<PackageReference Include="HttpMachine.PCL" Version="5.0.1" />
<PackageVersion Include="HttpMachine.PCL" Version="5.0.1" />Directory.Packages.props
<PackageReference Include="HttpMachine.PCL" />Project file
paket add HttpMachine.PCL --version 5.0.1
#r "nuget: HttpMachine.PCL, 5.0.1"
#:package HttpMachine.PCL@5.0.1
#addin nuget:?package=HttpMachine.PCL&version=5.0.1Install as a Cake Addin
#tool nuget:?package=HttpMachine.PCL&version=5.0.1Install as a Cake Tool
👁 .NET Standard
👁 .NET Standard
👁 .NET 6
👁 .NET 8
👁 .NET 9
Please star this project if you find it useful. Thank you.
This is a fork of the great work done by Benjamin van der Veen. The Original HttpMachine
HttpMachine.PCL is a combined C# HTTP request/reponse parser. It implements a state machine with Adrian Thurston's excellent state machine compiler, Ragel. Because Ragel supports C#, Java, Ruby, C++ and more.
HttpMachine is Copyright (c) 2011 Benjamin van der Veen. HttpMachine is licensed under the MIT License. See LICENSE.txt.
I've forked this project as Benjamin is no longer maintaining the work.
.NET Standard 2.0+ is now required minimun version.
Refactoring and simplification of use, have caused some namespaces to change. See example below for guidance for usage.
For instance, while still possible, it's no longer necessary to implement the interface IHttpCombinedParser, instead simply new up the HttpParserDelegate. Methods can be overrided if needed.
From version 3.1.0 and forward the ParserHandler must implement IHttpCombinedParser instead of using HttpCombinedParser (see example code below).
Additions to this version compared with the original HttpMachine by Benjamin van der Veen
MessageType to see what type was passed.IEnumerable<string>;class Program
{
static void Main(string[] args)
{
byte[] bArray;
using (var handler = new HttpParserDelegate())
using (var parser = new HttpCombinedParser(handler))
{
bArray = TestReponse();
Console.WriteLine(parser.Execute(bArray) == bArray.Length
? $"Reponse test succeed. Type identified is; {handler.HttpRequestResponse.MessageType} \r\n" +
$"Headers: \r\n" +
$"{string.Join("\r\n", handler.HttpRequestResponse.Headers.Select(h => $"{h.Key}: {string.Join(", ", h.Value)} "))}"
: $"Response test failed");
handler.HttpRequestResponse.Body.Position = 0;
var reader = new StreamReader(handler.HttpRequestResponse.Body);
var body = reader.ReadToEnd();
}
Console.WriteLine("\r\n\r\n");
using (var handler = new HttpParserDelegate())
using (var parser = new HttpCombinedParser(handler))
{
bArray = TestChunkedResponse();
Console.WriteLine(parser.Execute(bArray) == bArray.Length
? $"Chunked Response test succeed. Type identified is; {handler.HttpRequestResponse.MessageType}." +
$"Headers: \r\n" +
$"{string.Join("\r\n", handler.HttpRequestResponse.Headers.Select(h => $"{h.Key}: {string.Join(",", h.Value)} "))}"
: $"Chunked Response test failed");
handler.HttpRequestResponse.Body.Position = 0;
var reader = new StreamReader(handler.HttpRequestResponse.Body);
var body = reader.ReadToEnd();
}
}
// Test Response
private static string TestReponse()
{
var stringBuilder = new StringBuilder();
stringBuilder.Append("HTTP/1.1 200 OK\r\n");
stringBuilder.Append("CACHE-CONTROL: max-age = 10\r\n");
stringBuilder.Append("ST: upnp:rootdevice\r\n");
stringBuilder.Append("ST: upnp:rootdevice\r\n");
stringBuilder.Append("USN: uuid:73796E6F-6473-6D00-0000-0011322fe5f0::upnp:rootdevice\r\n");
stringBuilder.Append("EXT:\r\n");
stringBuilder.Append("SERVER: Synology/DSM/200.200.200.200\r\n");
stringBuilder.Append("LOCATION: http://200.200.200.101:5000/ssdp/desc-DSM-eth1.xml\r\n");
stringBuilder.Append("OPT: \"http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n");
stringBuilder.Append("01-NLS: 1\r\n");
stringBuilder.Append("BOOTID.UPNP.ORG: 1\r\n");
stringBuilder.Append("CONFIGID.UPNP.ORG: 1337\r\n");
stringBuilder.Append("\r\n");
return stringBuilder.ToString();
}
// Test request
private static string TestRequest()
{
var stringBuilder = new StringBuilder();
stringBuilder.Append("NOTIFY * HTTP/1.1\r\n");
stringBuilder.Append("HOST: 239.255.255.250:1900\r\n");
stringBuilder.Append("CACHE-CONTROL: max-age = 10\r\n");
stringBuilder.Append("LOCATION: http://www.bing.com\r\n");
stringBuilder.Append("NT: \"upnp:rootdevice\"\r\n");
stringBuilder.Append("NTS: ssdp:alive\r\n");
stringBuilder.Append("EXT:\r\n");
stringBuilder.Append("SERVER: Synology/DSM/200.200.200.100 UPnP/2.0 Test/1.0\r\n");
stringBuilder.Append("BOOTID.UPNP.ORG: 1\r\n");
stringBuilder.Append("CONFIGID.UPNP.ORG: 121212\r\n");
stringBuilder.Append("\r\n");
return stringBuilder.ToString();
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on HttpMachine.PCL:
| Package | Downloads |
|---|---|
|
WebsocketClientLite.PCL
A simple and light WebSocket client. Can be set to ignore SSL/TLS server certificate issues (use with care!). Easily and effectively observe incoming message using Reactive Extensions (Rx) |
|
|
SimpleHttpListener
Simple Http Listener This is the legacy version of Simple HTTP Listener. Please see project web site for a new version. |
|
|
SimpleHttpListener.Rx
The newer and greatly improved replacement of Simple HTTP Listener PCL. |
|
|
WebsocketClientLite.Rx2
Uses Rx v2.5.5 |
|
|
SwebSocket
An easy to use WebSocket library. |
This package is not used by any popular GitHub repositories.
Updated to .NET Standard v2.0, 2.1,.Net 6,.Net 8,.Net 9