|
351 | 351 |
|
352 | 352 | ;; help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
353 | 353 |
|
354 |
| -(define ((make-url-connector u ssl-ctx proxies) conn) |
355 |
| - (let ([ssl-ctx (if (promise? ssl-ctx) |
356 |
| - (force ssl-ctx) |
357 |
| - ssl-ctx)]) |
358 |
| - (cond |
359 |
| - ;; NOTE: The http-client automatically closes connections when |
360 |
| - ;; a response is chunked. So, don't be surprised if logging |
361 |
| - ;; indicates that connections aren't being reused in that case. |
362 |
| - [(http-conn-live? conn) |
363 |
| - (log-http-easy-debug "reusing connection to ~a" (pool-key u))] |
364 |
| - [else |
365 |
| - (log-http-easy-debug "connecting to ~a" (pool-key u)) |
366 |
| - (match-define (struct* url ([scheme scheme] [host host] [port port])) u) |
367 |
| - (case scheme |
368 |
| - [("http+unix") |
369 |
| - (define path (form-urlencoded-decode host)) |
370 |
| - (define-values (in out) |
371 |
| - (unix-socket-connect path)) |
372 |
| - (http-conn-open! conn "" #:ssl? (list #f in out close-output-port))] |
373 |
| - [else |
374 |
| - (or |
375 |
| - (for/first ([p (in-list proxies)] #:when ((proxy-matches? p) u)) |
376 |
| - ((proxy-connect! p) conn u ssl-ctx)) |
377 |
| - (http-conn-open! |
378 |
| - #:port (or port (if (equal? scheme "https") 443 80)) |
379 |
| - #:ssl? (and (equal? scheme "https") ssl-ctx) |
380 |
| - conn host))])]) |
381 |
| - conn)) |
| 354 | +(define ((make-url-connector u ssl-ctx-or-promise proxies) conn) |
| 355 | + (define ssl-ctx |
| 356 | + (force ssl-ctx-or-promise)) |
| 357 | + (cond |
| 358 | + ;; NOTE: The http-client automatically closes connections when |
| 359 | + ;; a response is chunked. So, don't be surprised if logging |
| 360 | + ;; indicates that connections aren't being reused in that case. |
| 361 | + [(http-conn-live? conn) |
| 362 | + (log-http-easy-debug "reusing connection to ~a" (pool-key u))] |
| 363 | + [else |
| 364 | + (log-http-easy-debug "connecting to ~a" (pool-key u)) |
| 365 | + (match-define (struct* url ([scheme scheme] [host host] [port port])) u) |
| 366 | + (case scheme |
| 367 | + [("http+unix") |
| 368 | + (define path (form-urlencoded-decode host)) |
| 369 | + (define-values (in out) |
| 370 | + (unix-socket-connect path)) |
| 371 | + (http-conn-open! conn "" #:ssl? (list #f in out close-output-port))] |
| 372 | + [else |
| 373 | + (or |
| 374 | + (for/first ([p (in-list proxies)] #:when ((proxy-matches? p) u)) |
| 375 | + ((proxy-connect! p) conn u ssl-ctx)) |
| 376 | + (http-conn-open! |
| 377 | + #:port (or port (if (equal? scheme "https") 443 80)) |
| 378 | + #:ssl? (and (equal? scheme "https") ssl-ctx) |
| 379 | + conn host))])]) |
| 380 | + conn) |
382 | 381 |
|
383 | 382 | (define (headers->list headers)
|
384 | 383 | (for/list ([(k v) (in-hash headers)])
|
|
0 commit comments