Created 2022-06-09
How to download a file over TLS using the Racket programming language. It is surprisingly straightforward. As with the Go example I gave earlier I have ignored verification of certificates. It looks a job of work.
(require openssl) (define-values (pin pout) (ssl-connect "gemini.conman.org" 1965)) (display "gemini://gemini.conman.org:1965/\r\n" pout) (flush-output pout) (close-output-port pout) (define (get-lines) (let loop () (define line (read-line pin)) (unless (eof-object? line) (displayln line) (loop)))) (get-lines) (close-input-port pin)