• This repository has been archived on 02/Aug/2019
  • Stars
    star
    108
  • Rank 319,730 (Top 7 %)
  • Language
    C#
  • License
    GNU Lesser Genera...
  • Created over 12 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple asynchronous .NET HTTP server

NHttp

LGPL License.

Download from NuGet.

Introduction

NHttp is a simple asynchronous HTTP server written in C# for the .NET framework.

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.

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

NHttp does not have a dependency on a logging framework, but uses Common.Logging if it's available. To enable logging, add a reference to Common.Logging (the version doesn't matter) to your project.

Bugs

Bugs should be reported through github at http://github.com/pvginkel/NHttp/issues.

License

NHttp is licensed under the LGPL 3.

More Repositories

1

PdfiumViewer

PDF viewer based on Google's PDFium.
C#
945
star
2

PdfiumBuild

Build scripts for the PDFium library.
C#
70
star
3

Expressions

Expression parser for C#, Flee and Visual Basic
C#
41
star
4

PdfViewer

.NET PDF viewer based on Chrome pdf.dll and xPDF
C#
35
star
5

CSharpSyntax

C# code generator based on the Roslyn API
C#
33
star
6

NHibernate.OData

OData parser for NHibernate.
C#
32
star
7

ProgressEncode

Implementation of the Progress OpenEdge ENCODE algorithm
C#
28
star
8

Microsoft.CodeAnalysis.CSharp.PatternMatching

Pattern matching for Roslyn syntax trees
C#
28
star
9

SystemEx

Collection of utilities for working with .NET and WinForms.
C#
26
star
10

PipeRPC

Simple, fast, JSON based RPC protocol for communicating with external processes using anonymous named pipes.
C#
26
star
11

ChromePdfViewer

.NET PDF viewer based on Chrome pdf.dll
C#
12
star
12

AutoMiner

Minecraft automatic miner for finding the best mining strategy
Java
11
star
13

graalvm-python-performance

GraalVM Python Performance
Python
9
star
14

XPdfNet

.NET wrapper for xPDF based on PDFLibNet
C
9
star
15

strtod

A high precision floating point implementation for Rust
Rust
7
star
16

NuGetUpdate

Setup and update system using NuGet as a deployment platform.
C#
7
star
17

VisualGit

Visual Studio source control extensions for Git
C#
7
star
18

CustomChrome

Library to ease adding custom chrome to a form with an implementation for the Visual Studio 2012 chrome
C#
6
star
19

ConvertAllToMp3

Convert all WAV files in a directory to MP3 using the LAME MP3 encoder.
C#
6
star
20

CrashReporter.NET

CrashCollector .NET library
C#
5
star
21

ApplicationHost

WinForms control for hosting .NET applications inside another .NET application
C#
5
star
22

ProtoVariant

VARIANT implementation in protobuf-net
C#
3
star
23

Tweakkit-Server

Form from http://www.afterkraft.net/tweakkit/tweakkit-server/
Java
3
star
24

InMemCached

In process .NET MemCached-ish library.
C#
3
star
25

FastProxy

Simple, fast, hackable, .NET proxy server for load testing and unit testing.
C#
3
star
26

JintDebugger

Debugger for Jint.
C#
2
star
27

GitVarInt

Variable length integer encoding based on Git VarInt and Protobuf ZigZag encoding.
C#
2
star
28

CrashCollector

CrashCollector AppEngine website
Java
2
star
29

ExtractPdfImages

Simple console app to extract images from PDF files using iTextSharp
C#
1
star
30

DapperContext

Automatic transaction management for Dapper
C#
1
star
31

GZipPullStream

GZipStream that allows reading compressed content, useful in e.g. ASP.NET MVC and ASP.NET Core MVC.
C#
1
star
32

ZigBeeHomeAutomation

Zigbee Home Automation implementation for Arduino
C++
1
star
33

HailStorm

XSD's for the Microsoft HailStorm project.
1
star
34

truss-compiler

C#
1
star
35

MoshRunner

Simple application to run the MSys2 version of Mosh
C#
1
star
36

ConvertWebPToJPeg

Convert WebP images to JPeg
C#
1
star
37

ZendeskExcelExport

Simple application to export all end user requests from Zendesk
C#
1
star
38

Q2ANotify

Windows desktop notifications for Question2Answer
C#
1
star
39

NTranslate

Translation application and build task for .NET WinForms applications
C#
1
star
40

ThermostatDisplay

C
1
star