hunt-http 0.5.0-beta.1

http module for hunt.


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

Build Status

hunt-http

Features

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

Note:

[1] Custom certificates
[2] WSS untested
[3] In-memory only
[4] In-memory only
[5] Download untested

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").registerWebSocket("/", 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
  • [ ] More unit tests

References

Dependencies:
hunt-net
Versions:
0.5.0-beta.1 2019-Nov-19
0.4.0-beta.5 2019-Oct-12
0.4.0-beta.4 2019-Oct-12
0.4.0-beta.3 2019-Sep-26
0.3.0 2019-Aug-08
Show all 11 versions
Download Stats:
  • 1 downloads today

  • 14 downloads this week

  • 93 downloads this month

  • 1027 downloads total

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