I don't really understand this bug. Ian's investigation isn't right, I don't think; the "delimited" port stuff from (web response) should make it correct to call get-bytevector-all on the response port. So I think there is not a client bug, but there may be a server bug on macOS. Can you retry on macOS with 2.0.11 and with 2.1.3 and see if the problem still exists?
Thanks, Andy On Sat 31 Aug 2013 09:11, Shane Celis <shane.ce...@gmail.com> writes: > Hi all, > > I found a bug in (web server) on Mac OS X, and when I compared against > GNU/Linux I seem to have found a bug in (web client) there. I've included a > script and further details below. > > #!/usr/local/bin/guile \ > -e main -s > !# > ;; guile-web-server-osx-bug.scm > ;; > ;; This script demonstrates a possible bug in Guile's web server on > ;; Mac OS X. And it demonstrates a possible bug in Guile's web client > ;; on GNU/Linux. > ;; > ;; Problem > ;; ======= > ;; > ;; Using Guile's (web server) with an example program, I ran into the > ;; following issue on Mac OS X: If I ran > ;; "./guile-web-server-osx-bug.scm server" and pointed my browser at > ;; http://localhost:8080, the first request would work and be > ;; displayed in my browser. The second request would timeout. I > ;; compared this with Guile on GNU/Linux and found that the (web > ;; server) worked fine, but the (web client) did not seem to work. > ;; > ;; > ;; Reproduction > ;; ============ > ;; > ;; The script takes an argument "server" or "client [hostname/ip]". > ;; When run as a server, it will say hello with an incremented > ;; counter. When run as a client, it will grab a couple of known > ;; sites gnu.org, fsf.org, and then try localhost or the given > ;; hostname on port 8080 twice, because on Mac OS X I saw the web > ;; server work on the first request but not the second. The > ;; hostname/ip the client is contacting is presumed to be a Guile web > ;; server on the other end but doesn't have to be. > ;; > ;; If there were no bugs, this script should work like this: > ;; $ ./guile-web-server-osx-bug.scm server & > ;; Web server replied 'Hello World! 0'. > ;; Web server replied 'Hello World! 1'. > ;; > ;; $ ./guile-web-server-osx-bug.scm client > ;; Getting http://gnu.org... response #<<response> [...] > ;; > ;; Getting http://fsf.org... response #<<response> [...] > ;; > ;; Getting http://localhost:8080... response #<<response> [...] > ;; > ;; Getting http://localhost:8080... response #<<response> [...] > ;; > ;; Mac OS X bug > ;; ------------ > ;; > ;; Info > ;; ---- > ;; > ;; $ uname -a > ;; Darwin mbp13.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 > 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64 > ;; > ;; $ bash ./build-aux/config.guess > ;; x86_64-apple-darwin12.4.0 > ;; > ;; $ guile --version > ;; guile (GNU Guile) 2.0.9 [...] > ;; > ;; $ ./config.status --config > ;; 'LDFLAGS=-L/opt/local/lib' 'CPPFLAGS=-I/opt/local/include' > ;; > ;; Running > ;; ------- > ;; > ;; $ ./guile-web-server-osx-bug.scm server > ;; Web server replied 'Hello World! 0'. > ;; > ;; -- > ;; > ;; $ ./guile-web-server-osx-bug.scm client > ;; Getting http://gnu.org... response #<<response> [...] > ;; > ;; Getting http://fsf.org... response #<<response> [...] > ;; > ;; Getting http://localhost:8080...SIGALRM called; timedout. > ;; > ;; If I try to connect to http://localhost:8080 through a web browser, > ;; it does not connect; however, the web server does report that it > ;; has replied. > ;; > ;; GNU/Linux bug > ;; ------------ > ;; > ;; Info > ;; ---- > ;; > ;; $ uname -a > ;; Linux debian 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1 i686 GNU/Linux > ;; > ;; $ guile --version > ;; guile (GNU Guile) 2.0.9 [...] > ;; > ;; $ bash ./build-aux/config.guess > ;; i686-pc-linux-gnu > ;; > ;; $ ./config.status --config > ;; > ;; Running > ;; ------- > ;; > ;; $ ./guile-web-server-osx-bug.scm server > ;; Web server replied 'Hello World! 0'. > ;; > ;; --- > ;; > ;; $ ./guile-web-server-osx-bug.scm client > ;; Getting http://gnu.org... response #<<response> [...] > ;; > ;; Getting http://fsf.org... response #<<response> [...] > ;; > ;; Getting http://localhost:8080...SIGALRM called; timedout. > ;; > ;; If I try to connect to http://localhost:8080 through a web browser, > ;; it works fine; so it seems like the (web client) is not working on > ;; GNU/Linux and the (web server) is not working on Mac OS X. > ;; > > (use-modules (web server) > (web client) > (ice-9 optargs)) > > (define count 0) > > (define (hello-world-handler request request-body) > (let ((reply (format #f "Hello World! ~a" count))) > (set! count (1+ count)) > (format #t "Web server replied '~a'.~%" reply) > (values '((content-type . (text/plain))) > reply))) > > (define (start-server) > (run-server hello-world-handler 'http '(#:port 8080))) > > (define (check-url url) > (format #t "Getting ~a..." url) > (format #t " response ~a~%~%" (http-get url))) > > (define* (run-client #:optional (ip "localhost")) > (alarm 10) > ;; Test some URLs that should work. > (check-url "http://gnu.org") > (check-url "http://fsf.org") > ;; Try the web server's URL now twice. > (check-url (format #f "http://~a:8080" ip)) > (check-url (format #f "http://~a:8080" ip))) > > (sigaction SIGALRM (lambda (sig) > (format #t "SIGALRM called; timedout.~%") > (exit 1))) > > > (define (main args) > (unless (or (= 2 (length args)) > (= 3 (length args))) > (format (current-error-port) "Usage: ~a <server|client [ip]>~%" (car > args)) > (exit 2)) > (cond > ((string= "server" (cadr args)) > (start-server)) > ((string= "client" (cadr args)) > (apply run-client (cddr args)))))