hunt-http 0.6.9

Hunt-Http is a flexible performant http server and client. Support HTTP/1.1, HTTP/2, WebSocket and static resource.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Build Status

hunt-http

Hunt-Http is a flexible performant http server and client written in D Programming Language.

Features

FeatureServerClient
HTTP 1.xtestedtested
HTTP/2testedtested
TLS 1.2testedtested[1]
WebSocket[2]testedtested
Routingtestednone
Cookietestedtested[3]
Sessiontested[4]tested
Form-Data[5]testedtested
X-WWW-Formtestedtested

Note:

[1] Mutual TLS supported
[2] WSS untested
[3] In-memory only
[4] In-memory only
[5] File upload and download

Simple codes

Using hunt-http build a web server

import hunt.http;

void main()
{
    auto server = HttpServer.builder()
        .setListener(8080, "0.0.0.0")
        .setHandler((RoutingContext context) {
            context.write("Hello World!");
            context.end();
        }).build();

    server.start();
}

Using hunt-http build a http client

import hunt.http;

import std.stdio;

void main()
{
    auto client = new HttpClient();

    auto request = new RequestBuilder().url("http://www.huntlabs.net").build();

    auto response = client.newCall(request).execute();

    if (response !is null)
    {
        writeln(response.getBody().asString());
    }
}

Using hunt-http build a websocket server

import hunt.http;

void main()
{
    auto server = HttpServer.builder()
        .setListener(8080, "0.0.0.0")
        .websocket("/ws", new class AbstractWebSocketMessageHandler {
            override void onText(WebSocketConnection connection, string text)
            {
                connection.sendText("Hello " ~ text);
            }
        }).build()

    server.start();
}

Avaliable versions

NameDescription
HUNTHTTPDEBUGUsed to log debug messages about Hunt-HTTP
HUNT_METRICUsed to enable some operations and APIs about metric

TODO

  • [ ] Reorganizing modules
  • [ ] PersistentCookieStore for HttpClient
  • [ ] Benchmark

References

Dependencies:
hunt-net
Versions:
0.6.11 2020-Sep-25
0.6.9 2020-Aug-25
0.6.8 2020-Aug-12
0.6.7 2020-Aug-11
0.6.5 2020-Jul-31
Show all 16 versions
Download Stats:
  • 2 downloads today

  • 12 downloads this week

  • 56 downloads this month

  • 2199 downloads total

Score:
1.7
Short URL:
hunt-http.dub.pm