standardize on storing urls as url structs internally instead of as strings
This commit is contained in:
12
net.rkt
12
net.rkt
@@ -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)
|
||||
|
Reference in New Issue
Block a user