From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: bug#39800: gnutls guile bug receiving https data Date: Tue, 03 Mar 2020 21:51:47 +0100 Message-ID: <87o8td17rw.fsf@igalia.com> References: <7923a31f-d916-01e9-be04-44bf1f131b2a@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="111220"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: ludo@gnu.org, 39800@debbugs.gnu.org To: "franco.rcr\@gmail.com" Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Tue Mar 03 21:53:10 2020 Return-path: Envelope-to: guile-bugs@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 1j9EXO-000Sm5-Ag for guile-bugs@m.gmane-mx.org; Tue, 03 Mar 2020 21:53:10 +0100 Original-Received: from localhost ([::1]:53620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9EXN-0001BM-DX for guile-bugs@m.gmane-mx.org; Tue, 03 Mar 2020 15:53:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48082) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9EXH-0001BC-MM for bug-guile@gnu.org; Tue, 03 Mar 2020 15:53:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9EXG-0006d1-FG for bug-guile@gnu.org; Tue, 03 Mar 2020 15:53:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34087) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j9EXG-0006cx-Bl for bug-guile@gnu.org; Tue, 03 Mar 2020 15:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j9EXG-0000ty-Av for bug-guile@gnu.org; Tue, 03 Mar 2020 15:53:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 03 Mar 2020 20:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39800 X-GNU-PR-Package: guile Original-Received: via spool by 39800-submit@debbugs.gnu.org id=B39800.15832687283401 (code B ref 39800); Tue, 03 Mar 2020 20:53:02 +0000 Original-Received: (at 39800) by debbugs.gnu.org; 3 Mar 2020 20:52:08 +0000 Original-Received: from localhost ([127.0.0.1]:40060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j9EWO-0000sn-1J for submit@debbugs.gnu.org; Tue, 03 Mar 2020 15:52:08 -0500 Original-Received: from fanzine.igalia.com ([178.60.130.6]:51937) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j9EWK-0000s4-S8 for 39800@debbugs.gnu.org; Tue, 03 Mar 2020 15:52:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From; bh=Q/EUypPXmIxr9C9K3THCbPYpqz2DMJE99gITE3YAfEI=; b=JZDPb6d7x9FGro05ylGLeiEfe4myisuCnWVTSDcJjkTBIkMHzQbcpsyOT6TK8FfWbp1vkN6Eqv9XtxnTI5qs+Az0AF9h2+HSRgbOYmGnLHJWIH9a+MJ24uHLnnE6tmrca1qoB/EBvakcAPgy9e7kImMGRNG34g7gfjIVIBn70Mak5nVazAG7npRxX/RvcleqirodqWsOAtF/RYlSFUuMHt+QvUh9zzkYZMpcsyDSU3Y/fmhrjmXQFN8ZQc0N5FKkPpTy8iSAQ7cEdPq5L6HoXx6UOLL5Ncbyvfn9RL7LiUHJQlZkvuVMpCCrxlokZFdJ4lMDTJkTE0M3VNgZBOatKw==; Original-Received: from [88.123.12.110] (helo=sparrow) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1j9EWD-0001cF-QA; Tue, 03 Mar 2020 21:51:58 +0100 In-Reply-To: <7923a31f-d916-01e9-be04-44bf1f131b2a@gmail.com> (franco's message of "Wed, 26 Feb 2020 16:20:09 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9608 Archived-At: Thanks very much for the report! I think this one may be a good one for Ludovic, if I may be so bold. Apologies for the top-post but I couldn't clip your excellent report. Cheers, Andy "franco.rcr@gmail.com" writes: > Hello, > I installed gnutls for guile and checked the gnutls module with this > simple code: > > > ;;Guile version 3.0 and gnutls=C2=A0 from git > > ,show version > GNU Guile 3.0.0.15-ff14b7 > > (gnutls-version) > $6 =3D "3.6.12" > > ;;Now, submitting this simple https request, you get an exception > (http-request "https://www.google.com") > ice-9/boot-9.scm:1669:16: In procedure raise-exception: > Throw to key `gnutls-error' with args `(# connessione TLS non =C3=83=C2=A8 stata terminata in modo corretto.> > read_from_session_record_port)'. > > ;;instead, without https there are no errors > (http-request "http://www.google.com") ;;works fine. > > > The error happens only on https://www.google.com and does not throw with > a lot of other https web sites. > Furthermore the error is not throw if the method is HEAD, so it is > related to the data part of the https answer. > I tried to enter in the internal implementation of the http web client > but after some tests I decided to do some simple tests at application > level. > I rewrote the get-bytevector-all, with a loop that reads one byte per > time and the error was thrown anyway. > I catched the error and I've got the complete answer from the google web > server. > > In the following there is my applicative solution, where I rewrote the > get-bytevector-all by adding the error checking and specifiyng to > http-request that the data has to be returned as a port (#:streaming? > #t). > > > ;;A macro to catch errors > (define-syntax my-noerr > =C2=A0 (syntax-rules () > =C2=A0=C2=A0=C2=A0 ((_ __error-return exp ...) > =C2=A0=C2=A0=C2=A0=C2=A0 (let > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((__st #f)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (catch #t > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (lambda() exp ...) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (lambda (k . p) __error-= return)))))) > > ;;The rewriting of get-bytevector-all > (defun get-bytevector-all (port) > =C2=A0 (u8-list->bytevector (let loop ((port port)) > =C2=A0=C2=A0=C2=A0=C2=A0 (let ((v (my-noerr (eof-object) (get-u8 port)))) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if (eof-object? v) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #nil > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cons v (loop port))))))) > > ;;the piece of code that now gives the correct result > =C2=A0 (let-values (((a b)(http-request "https://www.google.com" #:stream= ing? > #t))) > =C2=A0=C2=A0=C2=A0 (bytevector->string (get-bytevector-all b) "ISO-8859-1= ")) > > As conclusion I can say that web modules read correctly the http answers > and, with some (one for me, the google web site) https sites there is a > misinterpretation of EOF in the layer between http and https. > > Franco.