Ticket #1210: http-client-changes.diff

File http-client-changes.diff, 1.5 KB (added by rsenior, 6 years ago)
  • http-client.scm

     
    183182(define ssl-connect
    184183  (dynamic-import 'openssl 'ssl-connect (lambda (h p) (values #f #f))))
    185184
    186 (define (ensure-connection! uri)
     185(define (ensure-connection! uri conn-factory)
    187186  (or (get-connection uri)
    188187      (let* ((proxy ((determine-proxy) uri))
    189188             (remote-end (or proxy uri)))
    190189       (receive (in out)
    191190         (case (uri-scheme remote-end)
    192            ((#f http) (tcp-connect (uri-host remote-end) (uri-port remote-end)))
     191           ((#f http) ((or conn-factory tcp-connect) (uri-host remote-end) (uri-port remote-end)))
    193192           ((https) (receive (in out)
    194                         (ssl-connect (uri-host remote-end)
     193                        ((or conn-factory ssl-connect) (uri-host remote-end)
    195194                                     (uri-port remote-end))
    196195                      (if (and in out)  ; Ugly, but necessary
    197196                          (values in out)
     
    510509             (redirects 0)
    511510             (req req))
    512511    (condition-case
    513         (let* ((con (ensure-connection! (request-uri req)))
     512        (let* ((con (ensure-connection! (request-uri req) (request-conn-factory req)))
    514513               (req (add-headers (update-request
    515514                                  req port: (http-connection-outport con))))
    516515               ;; No outgoing URIs should ever contain credentials or fragments