From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.user Subject: Re: Using guile's web client Date: Thu, 15 Mar 2012 01:14:31 +0000 Message-ID: <877gymr7go.fsf@Kagami.home> References: <20120315000554.6e1918df@laptop.homenet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1331774089 25110 80.91.229.3 (15 Mar 2012 01:14:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Mar 2012 01:14:49 +0000 (UTC) Cc: Guile User To: Chris Vine Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Mar 15 02:14:48 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S7zHC-0006Gz-Nw for guile-user@m.gmane.org; Thu, 15 Mar 2012 02:14:46 +0100 Original-Received: from localhost ([::1]:36579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7zHC-0000J7-2m for guile-user@m.gmane.org; Wed, 14 Mar 2012 21:14:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7zH7-0000Hk-41 for guile-user@gnu.org; Wed, 14 Mar 2012 21:14:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7zH5-0007T3-7h for guile-user@gnu.org; Wed, 14 Mar 2012 21:14:40 -0400 Original-Received: from mail-wi0-f171.google.com ([209.85.212.171]:61659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7zH4-0007Sq-SK for guile-user@gnu.org; Wed, 14 Mar 2012 21:14:39 -0400 Original-Received: by wibhj13 with SMTP id hj13so6443479wib.12 for ; Wed, 14 Mar 2012 18:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=nMB9K9mlypWf/2LxH9T0x2CuYeT+YghzCrZQcHHsJHI=; b=HL+CB3Nwosub3Iu5BKz4VBk9GWPKPIeGT9SLXYf+Gkm6dAyx+P8XBSxAASvB3pAJXz TnqBe9I4Lw7mApOxBNq8jMgOMMfiyHGhoapW849DjzbnRQNhwuAgrpFxzGOmsiw+r47v imO3zdYC9udyGHzpgPUdPt8h55ONYh9riFGgh77R7Nkz7uPGrMJK8bYSzEHbg/h4EP+w kn5JfI0S7parX0Mb2PMHr7F5AQApxv97rrDFDeJr24aDTH3VXpAqQkI/LWd30Th4sMQT YQSHWDu7oPspkMt7fIr8gaijFPQzBa/kPwRLuG6lVOUMxprNLUEuAXpFg4I2j0MrTwPu +wkw== Original-Received: by 10.180.95.34 with SMTP id dh2mr11083881wib.15.1331774076861; Wed, 14 Mar 2012 18:14:36 -0700 (PDT) Original-Received: from Kagami.home (host86-151-78-130.range86-151.btcentralplus.com. [86.151.78.130]) by mx.google.com with ESMTPS id n15sm956635wiw.6.2012.03.14.18.14.34 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Mar 2012 18:14:35 -0700 (PDT) In-Reply-To: <20120315000554.6e1918df@laptop.homenet> (Chris Vine's message of "Thu, 15 Mar 2012 00:05:54 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.171 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9341 Archived-At: Chris Vine writes: > ((lambda() > (let ((uri (build-uri 'http > #:host "checkip.dyndns.com" > #:port 80 > #:path "/"))) > (display uri) > (newline) > (let ((r (http-get uri #:keep-alive? #t))) ^^ there's your problem > (if r > (begin > (display r)(newline) > ;; (display (read-response-body r))(newline) > ) > (begin > (display "Can't obtain response body") > (newline))))))) snip. > > The error is in the procedure call to read-response-body. Is this a > bug in guile-2, or am I doing something wrong? It's actually debatable whether or not this is your fault :). http-get returns 2 values: the response and the body. When you call read-response-body on the port, you are trying to read information that has already been read, and so it is coming up with an (eof-object) rather than the body. However, I notice that the manual doesn't actually say that it returns two values, so that'll need to be fixed. The correct way to write this code snippet is to use call-with-values (or sugar such as receive or let-values), instead of let. (let ((uri (build-uri 'http #:host "checkip.dyndns.com" #:port 80 #:path "/"))) (call-with-values (lambda () (http-get uri #:keep-alive? #t)) (lambda (request body) ...))) the request should (I think) always be a request object, so you don't need to check it with if. Though, the body may be #f, so it's worth checking that. -- Ian Price "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"