From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: mbcladwell@stihie.net Newsgroups: gmane.lisp.guile.user Subject: Re: open-socket-for-uri returns string, but integer is needed Date: Sun, 31 Jan 2021 02:27:18 -0600 Message-ID: <20210131022718.Horde.YYe38JjErTJFVHweOUaCqg4@www.stihie.net> References: <20210130073542.Horde.fnEmi9P7VryWvgZpnJCOvPv@www.stihie.net> <20210130092300.Horde.SbZuJPXArIaP1-IqlxpsQAz@www.stihie.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13052"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Horde Application Framework 5 Cc: guile-user To: Aleix Conchillo =?utf-8?b?RmxhcXXDqQ==?= Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Jan 31 09:27:34 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l6850-0003Gq-8u for guile-user@m.gmane-mx.org; Sun, 31 Jan 2021 09:27:34 +0100 Original-Received: from localhost ([::1]:58648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l684z-00039l-53 for guile-user@m.gmane-mx.org; Sun, 31 Jan 2021 03:27:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l684p-00039f-8A for guile-user@gnu.org; Sun, 31 Jan 2021 03:27:23 -0500 Original-Received: from gateway32.websitewelcome.com ([192.185.145.184]:42836) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l684n-0007dD-13 for guile-user@gnu.org; Sun, 31 Jan 2021 03:27:22 -0500 Original-Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 43528ACE586 for ; Sun, 31 Jan 2021 02:27:19 -0600 (CST) Original-Received: from gator3135.hostgator.com ([50.87.144.171]) by cmsmtp with SMTP id 684klARo5oE4D684llHhuR; Sun, 31 Jan 2021 02:27:19 -0600 X-Authority-Reason: nr=8 Original-Received: from gator3135.hostgator.com ([50.87.144.171]:36870) by gator3135.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1l684k-002U2x-Cq; Sun, 31 Jan 2021 02:27:18 -0600 Original-Received: from [100.0.196.207] ([100.0.196.207]) by www.stihie.net (Horde Framework) with HTTPS; Sun, 31 Jan 2021 02:27:18 -0600 In-Reply-To: Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3135.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stihie.net X-BWhitelist: no X-Source-IP: 50.87.144.171 X-Source-L: Yes X-Exim-ID: 1l684k-002U2x-Cq X-Source-Sender: gator3135.hostgator.com [50.87.144.171]:36870 X-Source-Auth: mbcladwell@stihie.net X-Email-Count: 1 X-Source-Cap: cGxhcGFuO3BsYXBhbjtnYXRvcjMxMzUuaG9zdGdhdG9yLmNvbQ== X-Local-Domain: yes Received-SPF: pass client-ip=192.185.145.184; envelope-from=mbcladwell@stihie.net; helo=gateway32.websitewelcome.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17217 Archived-At: I confirm that I get the same results as you with respect to timing. I suspect a configuration issue because other colleagues report that (open-socket-for-uri "https://blockchain.info/q/24hrprice") returns a socket integer. I (and you) get a string. I need to retrieve the uri output on a non-blocking port so I am trying to: (let* ((port (open-socket-for-uri "https://blockchain.info/q/24hrprice")) (portmod (fcntl port F_SETFL (logior O_NONBLOCK (fcntl port F_GETFD 0))))) (receive (response-status response-body) (http-get "https://blockchain.info/q/24hrprice" #:port portmod) response-body)) Even making it a one-liner does not help: (receive (response-status response-body) (http-get "https://blockchain.info/q/24hrprice" #:port (fcntl (open-socket-for-uri "https://blockchain.info/q/24hrprice") F_SETFL (logior O_NONBLOCK (fcntl (open-socket-for-uri "https://blockchain.info/q/24hrprice") F_GETFD 0)))) response-body) Thanks Mortimer Quoting Aleix Conchillo FlaquƩ : > Hi, > > I've tried this on macOS and I get the following (note the port type > is not socket, but neither file): > > scheme@(guile-user)> (open-socket-for-uri > "https://blockchain.info/q/24hrprice") > $7 = # > > If I do the following I get an error (see below): > > scheme@(guile-user)> (define s (open-socket-for-uri > "https://blockchain.info/q/24hrprice")) > > wait a bit... then: > > scheme@(guile-user)> (http-request > "https://blockchain.info/q/24hrprice" #:port s) > ice-9/boot-9.scm:1669:16: In procedure raise-exception: > Bad Read-Header-Line header: # > > However, if I do the following: > > scheme@(guile-user)> (http-request > "https://blockchain.info/q/24hrprice" #:port (open-socket-for-uri > "https://blockchain.info/q/24hrprice")) > > The request works fine. So, if I do the following quickly enough: > > scheme@(guile-user)> (define s (open-socket-for-uri > "https://blockchain.info/q/24hrprice")) > scheme@(guile-user)> (http-request > "https://blockchain.info/q/24hrprice" #:port s) > > it works fine. So it seems a timing issue. > > What is exactly failing and when in your case? > > Aleix > > On Sat, Jan 30, 2021 at 7:23 AM wrote: >> >> Yes it is installed. >> >> mbc@HP8300:~$ dpkg -s guile-gnutls >> Package: guile-gnutls >> Status: install ok installed >> >> How do I test that it is properly configured? For example I can: >> >> scheme@(guile-user)> (cdar (json-string->scm (utf8->string (receive >> (response-status response-body) >> (http-request >> "https://api.blockchain.com/v3/exchange/tickers/LTC-USD") >> response-body)))) >> $1 = 134.3 >> >> Thanks >> Mortimer >> >> Quoting Aleix Conchillo FlaquƩ : >> >> > Hi, >> > >> > This is just a guess but do you have GnuTLS Guile bindings installed? You >> > are using https on the first one. >> > >> > In Debian I believe it's guile-gnutls. >> > >> > Best, >> > >> > Aleix >> > >> > >> > On Sat, Jan 30, 2021, 5:38 AM wrote: >> > >> >> >> >> Hi, >> >> On Debian 10, Guile 3.0.4 I need to create a socket: >> >> >> >> mbc@HP8300:~$ guile >> >> GNU Guile 3.0.4 >> >> Copyright (C) 1995-2020 Free Software Foundation, Inc. >> >> Enter `,help' for help. >> >> scheme@(guile-user)> (use-modules (web client)) >> >> scheme@(guile-user)> (open-socket-for-uri >> >> "https://blockchain.info/q/24hrprice") >> >> $1 = # >> >> scheme@(guile-user)> (open-socket-for-uri "http://localhost:3000/123") >> >> $2 = # >> >> scheme@(guile-user)> >> >> >> >> A local http looks good - returns an integer socket. >> >> A remote https uri returns file 7f09b60b0e00 which is rejected by >> >> downstream functions requiring a port/integer e.g. (http-get .... >> >> #:port ) >> >> >> >> I get the same results on Guile 2.2.7 in a Guix protected environment. >> >> What am I doing wrong - how do I get an integer returned? >> >> Thanks >> >> Mortimer >> >> >> >> >> >> >> >> >>