web: Pass `AI_NUMERICSERV' when given a port number.
authorLudovic Courtès <ludo@gnu.org>
Fri, 12 Oct 2012 21:09:44 +0000 (23:09 +0200)
committerLudovic Courtès <ludo@gnu.org>
Fri, 12 Oct 2012 21:21:39 +0000 (23:21 +0200)
* module/web/client.scm (open-socket-for-uri)[addresses]: Pass
  AI_NUMERICSERV as the `getaddrinfo' hint when (uri-port URI) is true.

module/web/client.scm

index fcbfb15..27458a4 100644 (file)
 (define (open-socket-for-uri uri)
   "Return an open input/output port for a connection to URI."
   (define addresses
-    (getaddrinfo (uri-host uri)
-                 (cond
-                  ((uri-port uri) => number->string)
-                  (else (symbol->string (uri-scheme uri))))))
+    (let ((port (uri-port uri)))
+      (getaddrinfo (uri-host uri)
+                   (cond (port => number->string)
+                         (else (symbol->string (uri-scheme uri))))
+                   (if port
+                       AI_NUMERICSERV
+                       0))))
 
   (let loop ((addresses addresses))
     (let* ((ai (car addresses))