standardize on storing urls as url structs internally instead of as strings

This commit is contained in:
2025-09-05 18:18:14 -07:00
parent bd3f048595
commit 522d253c2a
2 changed files with 8 additions and 10 deletions

12
net.rkt
View File

@@ -1,21 +1,17 @@
#lang racket
(provide request)
(provide (contract-out
[request (-> url? (values integer? string? input-port?))]))
(require openssl)
(require net/url-string)
;; sends a request to a gemini server, and returns the status, header,
;; and the input port for the rest of the body.
;; this procedure will fail if the response is malformed, however, it
;; is not up to it to validate the contents of the response.
(define (request url-str)
(define url (string->url url-str))
(define (request url)
(define-values (c-in c-out)
(ssl-connect (url-host url)
(or (url-port url) 1965)))
(write-string url-str c-out)
(write-string (url->string url) c-out)
(write-string "\r\n" c-out)
(define-values (status header)