💾 Archived View for tozip.chickenkiller.com › 2022-06-09-racket-fetch-tls.gmi captured on 2023-06-16 at 16:14:28. 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)