(sigil http)
(sigil http) - HTTP Client and Server Library
High-level API for HTTP/1.1 client and server functionality. Supports both HTTP and HTTPS (via lazy-loaded sigil-tls).
Quick Start
(import (sigil http))
;; Simple GET request
(http-get "https://example.com/")
;; GET with JSON response parsing (requires sigil-json)
(http-get/json "https://api.example.com/users")
; => #{ users: #[...] }
;; POST with JSON body and response
(http-post/json "https://api.example.com/users"
#{ name: "Alice" email: "alice@example.com" })
;; Simple server
(http-serve (lambda (req)
(http-response/html 200 "<h1>Hello!</h1>"))
port: 8080)Client Functions
HTTP method conveniences: http-get, http-post, http-put, http-delete, http-head, http-options, http-patch.
JSON conveniences (require sigil-json): http-get/json, http-post/json, http-response-json.
Response Constructors
Use / variants for common response types:
http-response/text- Plain text with charsethttp-response/html- HTML contenthttp-response/json- JSON contenthttp-response/redirect- HTTP redirecthttp-response/error- Error page with statushttp-response/sse- Server-Sent Events stream
URL Handling
Functions for URL encoding, decoding, and parsing:
parse-url- Parse URL string into struct (scheme, host, port, path, query)url-decode- Decode percent-encoded strings (%20 → space, + → space)url-encode-value- Percent-encode a string for URL query valuesbuild-query-string- Build ?key=val&key2=val2 from an alist
;; Parse a URL into components
(define u (parse-url "https://example.com:8080/path?q=hello%20world"))
(url-scheme u) ; => "https"
(url-host u) ; => "example.com"
(url-port u) ; => 8080
(url-path u) ; => "/path"
(url-query u) ; => "q=hello%20world"
;; Decode percent-encoded strings
(url-decode "hello%20world") ; => "hello world"
(url-decode "name=foo+bar") ; => "name=foo bar"
;; Encode values for URLs
(url-encode-value "hello world") ; => "hello+world"
(build-query-string '(("q" . "hello world") ("page" . "1")))
; => "?q=hello+world&page=1"Sub-modules
For lower-level access, import sub-modules directly:
(sigil http request)- Request parsing and form data(sigil http response)- Response types and serialization(sigil http server)- Server implementation(sigil http client)- Client implementation(sigil http mime)- MIME type detection
Exports
http-requestvariable(No description)
http-request?variable(No description)
http-request-methodvariable(No description)
http-request-pathvariable(No description)
http-request-queryvariable(No description)
http-request-versionvariable(No description)
http-request-headersvariable(No description)
http-request-bodyvariable(No description)
http-request-contextvariable(No description)
http-request-headervariable(No description)
http-request-urivariable(No description)
http-request-content-lengthvariable(No description)
http-request-content-typevariable(No description)
http-request-context-refvariable(No description)
http-request-with-contextvariable(No description)
url-encode-valuevariable(No description)
build-query-stringvariable(No description)
build-repeated-paramsvariable(No description)
ensure-listvariable(No description)
url-decodevariable(No description)
parse-form-urlencodedvariable(No description)
parse-multipart-form-datavariable(No description)
extract-multipart-boundaryvariable(No description)
parse-form-datavariable(No description)
http-responsevariable(No description)
http-response?variable(No description)
http-response-statusvariable(No description)
http-response-headersvariable(No description)
http-response-bodyvariable(No description)
HTTP-OKvariable(No description)
HTTP-CREATEDvariable(No description)
HTTP-ACCEPTEDvariable(No description)
HTTP-NO-CONTENTvariable(No description)
HTTP-MOVED-PERMANENTLYvariable(No description)
HTTP-FOUNDvariable(No description)
HTTP-SEE-OTHERvariable(No description)
HTTP-NOT-MODIFIEDvariable(No description)
HTTP-TEMPORARY-REDIRECTvariable(No description)
HTTP-PERMANENT-REDIRECTvariable(No description)
HTTP-PARTIAL-CONTENTvariable(No description)
HTTP-BAD-REQUESTvariable(No description)
HTTP-UNAUTHORIZEDvariable(No description)
HTTP-FORBIDDENvariable(No description)
HTTP-NOT-FOUNDvariable(No description)
HTTP-METHOD-NOT-ALLOWEDvariable(No description)
HTTP-REQUEST-TIMEOUTvariable(No description)
HTTP-CONFLICTvariable(No description)
HTTP-GONEvariable(No description)
HTTP-LENGTH-REQUIREDvariable(No description)
HTTP-PAYLOAD-TOO-LARGEvariable(No description)
HTTP-URI-TOO-LONGvariable(No description)
HTTP-UNSUPPORTED-MEDIA-TYPEvariable(No description)
HTTP-INTERNAL-SERVER-ERRORvariable(No description)
HTTP-NOT-IMPLEMENTEDvariable(No description)
HTTP-BAD-GATEWAYvariable(No description)
HTTP-SERVICE-UNAVAILABLEvariable(No description)
HTTP-GATEWAY-TIMEOUTvariable(No description)
http-status-messagevariable(No description)
http-response/textvariable(No description)
http-response/htmlvariable(No description)
http-response/jsonvariable(No description)
http-response/not-foundvariable(No description)
http-response/redirectvariable(No description)
http-response/errorvariable(No description)
http-response/filevariable(No description)
parse-range-headervariable(No description)
response-compressible?variable(No description)
http-response-gzipvariable(No description)
http-response/ssevariable(No description)
http-response/sse-broadcastvariable(No description)
sse-eventvariable(No description)
sse-datavariable(No description)
make-http-servervariable(No description)
http-server?variable(No description)
http-server-portvariable(No description)
http-server-running?variable(No description)
http-server-socketvariable(No description)
http-server-startvariable(No description)
http-server-stopvariable(No description)
http-server-tickvariable(No description)
http-servevariable(No description)
mime-type-for-extensionvariable(No description)
mime-type-for-filevariable(No description)
mime-type-register!variable(No description)
parse-urlvariable(No description)
url-schemevariable(No description)
url-hostvariable(No description)
url-portvariable(No description)
url-pathvariable(No description)
url-queryvariable(No description)
http-getvariable(No description)
http-postvariable(No description)
http-putvariable(No description)
http-deletevariable(No description)
http-headvariable(No description)
http-optionsvariable(No description)
http-patchvariable(No description)
http-response-jsonvariable(No description)
http-get/jsonvariable(No description)
http-post/jsonvariable(No description)
http-downloadvariable(No description)
build-api-urlvariable(No description)
make-response-checkervariable(No description)
make-json-apivariable(No description)