From d14ecda913be98151f9c92f5f35e88cdb3457580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 18 Oct 2012 22:21:26 +0200 Subject: http/ftp: Tweak to avoid depending on libc's NSS. * guix/build/http.scm (open-connection-for-uri): New procedure. (http-fetch): Use it. Pass the result as a #:port argument to `http-get'. Add hack to modify the `set-port-encoding!' binding in (web response). * guix/ftp-client.scm (ftp-open): Add optional `port' parameter, defaulting to 21. When calling `getaddrinfo', convert PORT to a string and pass AI_NUMERICSERV when PORT is a number. --- guix/ftp-client.scm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'guix/ftp-client.scm') diff --git a/guix/ftp-client.scm b/guix/ftp-client.scm index a42d7956da..67c8472c7d 100644 --- a/guix/ftp-client.scm +++ b/guix/ftp-client.scm @@ -80,12 +80,18 @@ ((331) (%ftp-command (string-append "PASS " pass) 230 port)) (else (throw 'ftp-error port command code message)))))) -(define (ftp-open host) - "Open an FTP connection to HOST, and return it." +(define* (ftp-open host #:optional (port 21)) + "Open an FTP connection to HOST on PORT (a service-identifying string, +or a TCP port number), and return it." + ;; Use 21 as the default PORT instead of "ftp", to avoid depending on + ;; libc's NSS, which is not available during bootstrap. + (catch 'getaddrinfo-error (lambda () (define addresses - (getaddrinfo host "ftp")) + (getaddrinfo host + (if (number? port) (number->string port) port) + (if (number? port) AI_NUMERICSERV 0))) (let loop ((addresses addresses)) (let* ((ai (car addresses)) -- cgit v1.2.3