GlidingSquirrel 0.7.1-alpha

A http and websockets server implementation, written in C#. Is not
related to System.Net.HttpServer. Currently in alpha, so please report
any bugs you find by opening an issue against this project repository :-)

This is a prerelease version of GlidingSquirrel.
Install-Package GlidingSquirrel -Version 0.7.1-alpha
dotnet add package GlidingSquirrel --version 0.7.1-alpha
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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 :P

The logo is temporary!

Features

  • HTTP 1.0 / 1.1 (RFC 1945 / RFC 1616) supported (mostly - bug reports & pull requests welcome :D)
  • Uses C&sharp; 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 :D)
  • 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).

Useful Links

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 :P

The logo is temporary!

Features

  • HTTP 1.0 / 1.1 (RFC 1945 / RFC 1616) supported (mostly - bug reports & pull requests welcome :D)
  • Uses C&sharp; 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 :D)
  • 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).

Useful Links

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.7.1-alpha 146 8/26/2018
0.7.0-alpha 144 7/31/2018
0.6.3-alpha 185 6/21/2018
0.6.2-alpha 188 6/19/2018
0.6.1-alpha 261 12/23/2017
0.6.0-alpha 252 12/19/2017
0.5.0-alpha 204 12/18/2017