From: Greg Minshall <minshall@umich.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 72652@debbugs.gnu.org
Subject: bug#72652: 31.0.50; url-retrieve on non-existent domain gives no indication of error
Date: Fri, 16 Aug 2024 22:39:11 +0300 [thread overview]
Message-ID: <515941.1723837151@archlinux> (raw)
In-Reply-To: <86wmkg6hgd.fsf@gnu.org>
hi, Eli,
> On MS-Windows (mytry 2) signals an error:
i see. possibly the Emacs on windows is using a synchronous DNS
resolver (possibly not). but, an error is better than nothing.
> On GNU/Linux, I get this in the echo-area after about 2 sec:
>
> Contacting host: x.example.com:443
> url-retrieve returns *http x.example.com:443*
> buffer *http x.example.com:443* contents:
> "buffer *http x.example.com:443* contents:
> "
>
> IOW, I get an empty buffer. Why is that behavior a problem?
the problem is that there's no indication from url-retrieve that the
requested transfer has failed (or has in any way finished). the only
reason the message about the buffer was printed out was because the
mytry script times out after 5 seconds, prints out whatever might be in
the buffer.
so, a program that calls url-retrieve for an unknown host is never
notified that anything happened.
if some sort of error is detected synchronous with the call to
url-retrieve (i.e., before url-retrieve returns to its caller),
signaling an error seems fine.
in the case where the error is detected later, then i think (if
possible) url-retrieve should cause a callback to happen, with the
`:error` data in the status parameter specifying something like "unknown
host".
in the case of (mytry 1), there is a callback (to the callback routine
specified in the invocation of url-retrieve) which passes an error
indication:
----
called back: ((:error (error http 500)
----
(one can modify mytry to print out the status given to the
callback routine -- see below.)
hth.
cheers, Greg
----
modified mytry: prints out status parameter to callback:
----
;;; ... -*- lexical-binding: t -*-
(defun mysage (&rest args)
"Like (message), but send ARGS to stdout, even in batch mode.
\(In batch mode, (message) sends to stderr; the prin1, etc.,
send to stdout."
(princ (format "%s\n" (apply 'format args))))
(defun mytry (n)
"Try url-retrieve on a URL. N is 0, 1, or 2."
(let* ((urls '("https://example.com/index.html"
"https://example.com/index99.html"
"https://x.example.com/index.html"))
(buffer
(url-retrieve (nth n urls)
(lambda (&rest results)
(mysage "called back: %s" results))
nil)))
(mysage "url-retrieve returns %s" buffer)
(sleep-for 5)
(with-current-buffer buffer
(mysage "buffer %s contents: %s" buffer (buffer-substring (point-min) (point-max))))))
next prev parent reply other threads:[~2024-08-16 19:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 4:34 bug#72652: 31.0.50; url-retrieve on non-existent domain gives no indication of error Greg Minshall
2024-08-16 6:11 ` bug#72652: sentinel Greg Minshall
2024-08-16 7:43 ` bug#72652: 31.0.50; url-retrieve on non-existent domain gives no indication of error Eli Zaretskii
2024-08-16 19:39 ` Greg Minshall [this message]
2024-08-17 5:50 ` Eli Zaretskii
2024-08-17 12:54 ` Greg Minshall
2024-09-13 1:50 ` Dmitry Gutov
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/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=515941.1723837151@archlinux \
--to=minshall@umich.edu \
--cc=72652@debbugs.gnu.org \
--cc=eliz@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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).