Skip to content

Instantly share code, notes, and snippets.

public interface IApplication {
// either may throw exception
IAsyncResult BeginInvoke(IRequest request, AsyncCallback callback, object state);
IResponse EndInvoke(IAsyncResult result);
}
@bvanderveen
bvanderveen / TransformMiddleware.cs
Created December 19, 2010 05:36
An IApplication which transforms requests/responses to/from a wrapped IApplication
// this snippet assumes the IAsyncResult implementation provided here:
// http://msdn.microsoft.com/en-us/magazine/cc163467.aspx
using System;
using Owin;
namespace TransformMiddleware
{
// Defines a tranformation of an HTTP context.
public interface IHttpTransform
@bvanderveen
bvanderveen / Rx.cs
Created December 22, 2010 02:29
Examples of wrapping an APM operation using the Reactive Framework and the Task Parallel Library
using System;
using System.Disposables;
using System.IO;
using System.Linq;
using System.Threading;
namespace RxVsTplSamples
{
public static partial class Extensions
{
@bvanderveen
bvanderveen / OwinDraft2.cs
Created December 22, 2010 09:13
OWIN, take 2
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Owin
{
public struct OwinResponse
{
public string Status;
public IDictionary<string, IEnumerable<string>> Headers;
public IEnumerable<object> Body;
@bvanderveen
bvanderveen / Rx.cs
Created December 25, 2010 04:43
Examples of implementing an APM operation using the Reactive Framework and the Task Parallel Library
using System;
using System.Disposables;
using System.Linq;
using System.Threading;
namespace RxVsTplSamples
{
public class RxAsyncOperation<TArg, TResult>
{
Func<TArg, IObservable<TResult>> operation;
@bvanderveen
bvanderveen / ParserDriver.cs
Created January 13, 2011 23:46
Janky example of how to use JacksonH's C# port of a Java port of Ryan Dahl's http-parser
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ParserDriver
{
public class Parser
{
public string Method;
@bvanderveen
bvanderveen / Http.cs
Created February 19, 2011 21:52
Upcoming Kayak interface
using System;
using System.Collections.Generic;
namespace Kayak.Http
{
public class HttpRequestEventArgs : EventArgs
{
public IHttpServerRequest Request { get; internal set; }
public IHttpServerResponse Response { get; internal set; }
}
@bvanderveen
bvanderveen / Gate.Kayak.cs
Created March 21, 2011 09:57
Untested sketch of Kayak support in Gate.
using System;
using System.Collections.Generic;
using Kayak.Http;
// utterly, completely, maximally untested sketch of an OWIN-Kayak adapter.
namespace Gate.Kayak
{
using Application =
Action<
IDictionary<string, object>,
@bvanderveen
bvanderveen / Http.cs
Created May 1, 2011 15:19
Interface-based API for New Kayak
using System;
using System.Collections.Generic;
namespace Kayak.Http
{
public struct HttpRequestHead
{
public string Method;
public string Uri;
public Version Version;
@bvanderveen
bvanderveen / BeginSendSocketTest.cs
Created June 1, 2011 17:34 — forked from jasonsirota/BeginSendSocketTest.cs
BeginSend Socket Test Mon
/*
I have a piece of .NET code that uses Asynchronous sockets that I want to cross
compile and run on Mono, however, when I attempt to run it, the AsyncCallback for
the BeginSend never gets called. I've boiled down the problem to a very simple
example. The example does not ever hit the callback, I have tried the following
configurations:
OS: Ubuntu 10.10 (Maverick Meerkat)
Mono 2.8.2 using Nathan Bridgewater's install shell script
Mono 2.10.2 using Nathan Bridgewater's updated shell script