GlidingSquirrel 0.7.1-alpha

This is a prerelease version of GlidingSquirrel.
dotnet add package GlidingSquirrel --version 0.7.1-alpha                
NuGet\Install-Package GlidingSquirrel -Version 0.7.1-alpha                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GlidingSquirrel" Version="0.7.1-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GlidingSquirrel --version 0.7.1-alpha                
#r "nuget: GlidingSquirrel, 0.7.1-alpha"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GlidingSquirrel as a Cake Addin
#addin nuget:?package=GlidingSquirrel&version=0.7.1-alpha&prerelease

// Install GlidingSquirrel as a Cake Tool
#tool nuget:?package=GlidingSquirrel&version=0.7.1-alpha&prerelease                

alternate text is missing from this package README image GlidingSquirrel

A http (and Websockets!) server, implemented in C#.

Originally built for the /r/dailyprogrammer hard challenge #322.

GlidingSquirrel is currently in alpha testing! Don't use this in production unless you really know what you're doing šŸ˜›

The logo is temporary!

Features

  • HTTP 1.0 / 1.1 (RFC 1945 / RFC 1616) supported (mostly - bug reports & pull requests welcome šŸ˜„)
  • Uses Cā™Æ 7
  • Does not have anything to do with System.Net.HttpServer whatsoever at all
  • Easily extendable (it's an abstract class)
  • Supports client requests with bodies (e.g. POST and PUT, but any http verb with a content-length will work)
  • Supports HEAD requests
  • Parses and respects the Accepts HTTP header
  • Supports keep-alive connections (HTTP 1.1 only, of course)
  • Supports Websockets (RFC 6455, Initial implementation, version 13 only, needs thorough testing - detailed bug reports welcome šŸ˜„)
  • Global configurable logging level
  • Ability to cleanly shut the server down

Todo

  • Trailing headers
  • Give implementors of WebsocketServer a cleaner way to decide whether they want to accept a connection or not

Getting Started

Start by making sure your project is using the .NET framework 4.6.2 or higher, and then install the GlidingSquirrel (pre-release) NuGet package. Here's an overview of the important classes you'll probably come into contact with:

  • HTTP
    • SBRL.GlidingSquirrel.Http.HttpServer - The main HTTP server class. Inherit from this to create a HTTP server.
    • SBRL.GlidingSquirrel.Http.HttpRequest - Represents HTTP requests incoming from clients.
    • SBRL.GlidingSquirrel.Http.HttpResponse - Represents the HTTP response that will be sent by to the client.
    • SBRL.GlidingSquirrel.Http.HttpMessage - The base class that HttpRequest and HttpResponse inherit from.
    • SBRL.GlidingSquirrel.Http.HttpResponseCode - Represents a HTTP response code that is returned to the client.
  • Websockets
    • SBRL.GlidingSquirrel.Websocket.WebsocketServer - The main Websockets server class. Inherit from this to create a websockets-capable server!
    • SBRL.GlidingSquirrel.Websocket.WebsocketClient - Represents a single Websocket client.
    • SBRL.GlidingSquirrel.Websocket.WebsocketFrame - Represents a single frame received from / about to be sent to a client.
  • SBRL.GlidingSquirrel.Log - The global logging class that all log messages flow through. Can be tuned to increase / decrease the verbosity of the logging messages.
  • SBRL.GlidingSquirrel.LogLevel - The enum that contains the different logging levels.

The best way I'm currently aware of to get an idea as to how to utilise this library for yourself is to take a look at the demo server modes built into the CLI project that's part of the main GlidingSquirrel solution.

GlidingSquirrel now has automatically generated documentation with mdoc! You can find it here.

Things to watch out for

  • If you don't set the response body (either with response.SetBody() or response.Body = StreamReader), then no response will be sent to the browser and clients will sit there waiting for a response indefinitely!
  • If you set the response body directly via response.Body = StreamReader, some clients may require the ContentLength property to be specified also (response.SetBody() does this automatically) - especially if a client is using a persistent connection.
  • As the GlidingSquirrel supports HTTP/1.1 persistent connection, you can tell it what (not?) to do with a connection either before or after sending a response via the HttpConnectionAction enum that you return a value from in HandleRequest (or HandleHttpRequest for websockets servers).
Product Compatible and additional computed target framework versions.
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.7.1-alpha 695 8/26/2018
0.7.0-alpha 601 7/31/2018
0.6.3-alpha 695 6/21/2018
0.6.2-alpha 691 6/19/2018
0.6.1-alpha 827 12/23/2017
0.6.0-alpha 840 12/19/2017
0.5.0-alpha 730 12/18/2017