AtlatestRepositorysigil-http
sigil-http / treeREADME.md
1
# sigil-http3
HTTP/1.1 client and server library for [Sigil](https://codeberg.org/sigil/sigil).5
Provides HTTP/1.1 support for building web applications and APIs. Primary6
use cases are serving documentation sites and game server APIs.8
This package was extracted from the sigil monorepo — the in-tree history9
under `packages/sigil-http/` is preserved here as `master`.11
## Usage13
```scheme14
(import (sigil http))16
;; Client — GET / POST / PUT / DELETE17
(let ((response (http-get "https://example.com/")))18
(display (http-response-body response)))20
(http-post "https://api.example.com/users"21
"{\"name\":\"Alice\"}"22
'(("Content-Type" . "application/json")))24
;; Server25
(http-serve26
port: 808027
handler: (lambda (request)28
(http-response 200 '(("Content-Type" . "text/plain"))29
"Hello, world!")))30
```32
See `docs/http.md` for the full API reference, including streaming bodies,33
Server-Sent Events, and low-level request/response manipulation.35
## Binary uploads37
`(sigil http client)` exports `http-fetch-bytes`. Its `body:` argument38
accepts a string or bytevector; use bytevectors for images and other binary data.39
The response has `status:`, an ordered `headers:` alist, and bytevector `body:`.40
Redirects are returned to the caller and transport failures return `#f`.42
```scheme43
(import (sigil http client))44
(http-fetch-bytes 'PUT "https://example.com/object"45
headers: #{ content-type: "application/octet-stream" }46
body: image-bytes timeout: 30)47
```49
Run `node test/integration/run-upload-tests.mjs` (Node 18+) for the full Sigil50
suite plus an ephemeral loopback server exercising empty and 2 MB binary bodies.52
## Dependencies54
- `sigil-stdlib`, `sigil-socket`, `sigil-tls` — pinned via `from-git`55
against the sigil monorepo (`^0.13.1`). Resolved automatically by56
`sigil deps install`.58
## Build60
```bash61
sigil deps install62
sigil build63
sigil test64
```66
## Development against a local sigil checkout68
`dev-redirects.sgl` redirects `codeberg:sigil/sigil` to `../sigil`. Pass69
it to the build CLI when you need to test against unreleased monorepo70
changes:72
```bash73
sigil build --redirects dev-redirects.sgl74
```76
Otherwise, let `sigil deps install` pull the pinned monorepo tag.78
## License80
BSD-3-Clause. See `package.sgl` for author list.82
### Binary multipart forms84
`parse-form-data` prefers a request's raw bytes for multipart input. File parts85
return a bytevector in `content:`; ordinary fields are independently decoded as86
UTF-8. Consumers that previously treated uploaded file content as text should87
decode explicitly only for text formats. `parse-multipart-form-data-bytes` is88
also available directly. It requires CRLF framing and a closing delimiter, with89
a maximum of 128 parts and 16 KiB of headers per part. The server request-size90
limit still controls the total body. The older string parser remains available.