sigildocs

(sigil http client)

(sigil http client) - HTTP Client Implementation

Provides HTTP/1.1 client functionality for making requests to HTTP and HTTPS servers.

Example: (import (sigil http client)) (let ((response (http-get "https://example.com/"))) (display (http-response-body response)))

Exports

urlprocedure

Construct a url struct.

url?procedure

Test if a value is a url struct.

url-schemeprocedure

Get the scheme field of a url struct.

url-hostprocedure

Get the host field of a url struct.

url-portprocedure

Get the port field of a url struct.

url-pathprocedure

Get the path field of a url struct.

url-queryprocedure

Get the query field of a url struct.

parse-urlprocedure

Parse a URL string into a url record Supports: http://host:port/path?query and https://...

Connect to a server, using TLS if scheme is https Returns connection object or #f on failure

conn-writeprocedure

Write data to connection (socket or TLS)

conn-readprocedure

Read data from connection (socket or TLS)

conn-closeprocedure

Close connection

Build HTTP request string

Build header lines from headers (dict or alist)

Parse HTTP status line Returns (version status-code reason) or #f

Parse response headers from data Returns dict with keyword keys

Read HTTP response from connection Returns http-response or #f on error

read-all-dataprocedure

Read all data from connection until closed

Parse HTTP response from string

Decode chunked transfer encoding Format: <hex-size>rn<data>rn ... 0rnrn

find-crlfprocedure

Find position of rn starting at pos

Convert hex string to number

Find the end of HTTP headers (position of rnrn)

skip-crlfprocedure

Skip CRLF sequence(s) at position

Parse HTTP response body as JSON.

Returns the parsed JSON value, or #f if the response is #f or parsing fails. Requires sigil-json package.

(let ((res (http-get "https://api.example.com/data")))
  (http-response-json res))
; => #{ users: #[...] count: 42 }
http-requestprocedure

HTTP Request Record Uses define-struct for immutability and functional updates via inherit

Re-exported from (sigil http request)

Test if a value is a http-response struct.

Re-exported from (sigil http response)

Get the status field of a http-response struct.

Re-exported from (sigil http response)

Get the headers field of a http-response struct.

Re-exported from (sigil http response)

Get the body field of a http-response struct.

Re-exported from (sigil http response)