unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: "franco.rcr@gmail.com" <franco.rcr@gmail.com>
To: 39800@debbugs.gnu.org
Subject: bug#39800: gnutls guile bug receiving https data
Date: Wed, 26 Feb 2020 16:20:09 +0100	[thread overview]
Message-ID: <7923a31f-d916-01e9-be04-44bf1f131b2a@gmail.com> (raw)

Hello,
I installed gnutls for guile and checked the gnutls module with this 
simple code:


;;Guile version 3.0 and gnutls  from git

,show version
GNU Guile 3.0.0.15-ff14b7

(gnutls-version)
$6 = "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 `(#<gnutls-error-enum La 
connessione TLS non è 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
   (syntax-rules ()
     ((_ __error-return exp ...)
      (let
          ((__st #f))
        (catch #t
          (lambda() exp ...)
          (lambda (k . p) __error-return))))))

;;The rewriting of get-bytevector-all
(defun get-bytevector-all (port)
   (u8-list->bytevector (let loop ((port port))
      (let ((v (my-noerr (eof-object) (get-u8 port))))
        (if (eof-object? v)
        #nil
        (cons v (loop port)))))))

;;the piece of code that now gives the correct result
   (let-values (((a b)(http-request "https://www.google.com" 
#:streaming? #t)))
     (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.






             reply	other threads:[~2020-02-26 15:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 15:20 franco.rcr [this message]
2020-03-03 20:51 ` bug#39800: gnutls guile bug receiving https data Andy Wingo
2020-03-06 22:46 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7923a31f-d916-01e9-be04-44bf1f131b2a@gmail.com \
    --to=franco.rcr@gmail.com \
    --cc=39800@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).