Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huntlabs/hunt-http
http library for D, support http 1.1 / http 2.0 (http2) / websocket server and client.
https://github.com/huntlabs/hunt-http
http-client http-protocol http-server http2 hunt websocket
Last synced: 5 days ago
JSON representation
http library for D, support http 1.1 / http 2.0 (http2) / websocket server and client.
- Host: GitHub
- URL: https://github.com/huntlabs/hunt-http
- Owner: huntlabs
- License: apache-2.0
- Created: 2018-07-18T07:59:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-17T13:49:58.000Z (over 2 years ago)
- Last Synced: 2024-08-05T01:10:59.158Z (4 months ago)
- Topics: http-client, http-protocol, http-server, http2, hunt, websocket
- Language: D
- Homepage:
- Size: 1.85 MB
- Stars: 32
- Watchers: 5
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-d - hunt-http - HTTP/1 and HTTP/2 protocol library for D. (Web Frameworks / Bare metal / kernel development)
README
[![Build Status](https://travis-ci.org/huntlabs/hunt-http.svg?branch=master)](https://travis-ci.org/huntlabs/hunt-http)
# hunt-http
Hunt-Http is a flexible performant http server and client written in D Programming Language.## Features
| Feature | Server | Client |
|--------|--------|--------|
| HTTP 1.x | tested | tested |
| HTTP/2 | tested | tested |
| TLS 1.2 | tested | tested[1] |
| WebSocket[2] | tested | tested |
| Routing | tested | none |
| Cookie | tested | tested[3] |
| Session | tested[4] | tested |
| Form-Data[5] | tested | tested |
| X-WWW-Form | tested | tested |**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
```D
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
```D
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
```D
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
| Name | Description |
|--------|--------|
| HUNT_HTTP_DEBUG | Used to log debug messages about Hunt-HTTP |
| HUNT_METRIC | Used to enable some operations and APIs about metric |## TODO
- [ ] Reorganizing modules
- [ ] PersistentCookieStore for HttpClient
- [ ] Benchmark## References
- Eclipse Jetty 9.4.x, [https://github.com/eclipse/jetty.project](https://github.com/eclipse/jetty.project)