#Axionetd - A simple HTTP server for unix systems

19 messages · Page 1 of 1 (latest)

earnest sage
#

AxionetD

AxionetD is a lightweight HTTP server framework written in C. It provides a minimal and efficient way to create HTTP servers with custom routing and request handling using raw sockets.

Features

  • Raw TCP-based HTTP server
  • Simple routing system (path -> handler)
  • Custom request parsing (method and path)
  • Dynamic response handling
  • SIGINT (Ctrl+C) graceful shutdown support
  • Minimal dependencies (POSIX sockets + standard C library)

Project Structure

include/     - Header files
src/         - Source files

Example Usage

Axionet* server = initServer(8000, 10);

addRoute(server, "/", rootHandler);
addRoute(server, "/hello", helloHandler);

startServer(server);

Route Handler Example

AxioResponse* rootHandler(AxioRequest* request) {
    AxioResponse* response = malloc(sizeof(AxioResponse));

    response->response =
        "HTTP/1.1 200 OK\r\n"
        "Content-Type: text/plain\r\n"
        "\r\n"
        "Hello, world!";

    return response;
}

Building

Build using make:

make

this produces a libaxionetd.a file.

Notes

  • Routes are matched using exact string comparison
  • Responses are manually managed (must be freed)
  • Only basic HTTP request parsing is currently implemented

License

GPL-3.0 license

earnest sage
#

Added header parsing alongside fixing response generation

earnest sage
#

Added support for custom user headers:

Example:

AxioResponse* root(AxioRequest* request) {
    AxioHeader headers[] = {
        {"Content-Type", "text/html"}
    };

    AxioResponse* resp = initResponse("<h1>Hello, World!</h1>", 200, headers, 1);
    return resp; 
}
earnest sage
#

Optimized request handling by removing memory allocation for AxioRequest alongside several more minor changes

earnest sage
#

Laid foundation for JSON support by adding yyjson support (request->json = yyjson_doc)

#

Added AxioRequest_JSONGetObj

earnest sage
#

Added AxioRequest_JSONGetInt, AxioRequest_JSONGetBool, AxioRequest_JSONGetStr

earnest sage
#

Added basic threading support alongside python wrapper.

earnest sage
#

Added AxionetInstance class for python wrapper to simplify library usage

earnest sage
#

Added AxionetInstance.route method alongside allowing handlers to return tuples as a response [python-wrapper]

earnest sage
#

Added query parsing [C]

earnest sage
earnest sage
#
[vxid-dev@VoidDev ~]$ wrk -t4 -d30 -c900 http://localhost:8000
Running 30s test @ http://localhost:8000
  4 threads and 900 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    10.01ms    2.06ms  22.17ms   74.64%
    Req/Sec    21.74k     2.39k   25.36k    66.50%
  2596864 requests in 30.03s, 190.70MB read
Requests/sec:  86487.17
Transfer/sec:      6.35MB
[vxid-dev@VoidDev ~]$ 

Added memory pools (~40-45k reqs/s -> ~81-87k reqs/s)

==89003== HEAP SUMMARY:
==89003==     in use at exit: 0 bytes in 0 blocks
==89003==   total heap usage: 13 allocs, 13 frees, 986,001,472 bytes allocated
==89003== 
==89003== All heap blocks were freed -- no leaks are possible
==89003== 
==89003== For lists of detected and suppressed errors, rerun with: -s

(previous amount of allocs was ~1.5m-2.0m)

earnest sage
brisk stone
#

rewrite in rust

earnest sage
brisk stone
#

something as http srv should tho

frank coyote