- Add `parse_query` and `format_query` - Bug fix: trailing semicolons in cookies are now handled↗ https://github.com/hamer1818/tulpar-pkg-http-utils/releases/download/v0.2.0/http_utils.tpr
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
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
| Function | Returns |
|---|---|
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
- Initial release: `parse_request`, `parse_headers`, `status_text`.↗ https://github.com/hamer1818/tulpar-pkg-http-utils/releases/download/v0.1.0/http_utils.tpr