← all packages

http_utils

Helpers for building and parsing HTTP/1.1 messages by hand — request line splitting, header parsing, query-string decoding, status-code helpers.

Install

Latest (0.2.0)
tulpar pkg add http_utils@0.2.0

Make sure your tulpar.toml has [registry] url = "https://pkg.tulparlang.dev", then run tulpar pkg install.

Details

Repository
https://github.com/hamer1818/tulpar-pkg-http-utils
License
MIT
Author
Hamza ORTATEPE
Tags
httputility

A small toolbox of pure-string helpers for working with raw HTTP messages. Useful when you’ve rolled your own server with socket_* and don’t want to pull the full wings framework, or when you need to parse stored request payloads in tests.

Functions

FunctionReturns
parse_request(raw){ method, path, version, headers, body }
parse_query(qs)arrayJson of decoded key→value pairs
format_query(json)URL-encoded ?k=v&k2=v2… string
parse_headers(block)arrayJson of header name→value
status_text(code)Standard reason phrase for an integer status

Example

import "http_utils";

str raw = "GET /search?q=tulpar HTTP/1.1\r\nHost: example.com\r\n\r\n";
arrayJson req = parse_request(raw);
arrayJson params = parse_query(req["path"]);
print(params["q"]);   // "tulpar"

Versions