💾 Archived View for tozip.chickenkiller.com › 2022-06-09-racket-fetch-tls.gmi captured on 2023-03-20 at 17:52:18. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-07-16)

-=-=-=-=-=-=-

Fetch TLS(gemini) using Racket

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)