https pasted by S-liao on Tue Feb 18 14:25:10 2025

(import (chicken base))
(import (chicken io))
(import (chicken tcp))
(import http-client)
(import intarweb)
(import openssl)
(import uri-common)

(define (http-server-connector uri proxy)
  (let ((remote-end (or proxy uri)))
    (case (uri-scheme remote-end)
      ((#f http) (tcp-connect (uri-host remote-end) (uri-port remote-end)))
      ((https) (receive (in out)
                   (ssl-connect* hostname: (uri-host remote-end)
                                 port: (uri-port remote-end)
                                 sni-name: #t
                                 verify?: #t) ; accept invalid certs
                 (values in out)))
      (else (error "Unsupported protocol" (uri-scheme remote-end))))))


(server-connector http-server-connector)

(define url "https://repology.org")
(print (with-input-from-request url #f read-string))

Adding protocol added by sjamaan on Tue Feb 18 14:41:06 2025

(define (http-server-connector uri proxy)
  (let ((remote-end (or proxy uri)))
    (case (uri-scheme remote-end)
      ((#f http) (tcp-connect (uri-host remote-end) (uri-port remote-end)))
      ((https) (receive (in out)
                   (ssl-connect* hostname: (uri-host remote-end)
                                 port: (uri-port remote-end)
                                 sni-name: #t
                                 protocol: 'tlsv13
                                 verify?: #t) ; accept invalid certs
                 (values in out)))
      (else (error "Unsupported protocol" (uri-scheme remote-end))))))