|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;; This file:
;; http://angg.twu.net/elisp/url-retrieve-test.el.html
;; http://angg.twu.net/elisp/url-retrieve-test.el
;; (find-angg "elisp/url-retrieve-test.el")
;; Author: Eduardo Ochs <eduardoochs@gmail.com>
;; Version: 2021oct03
;; Public domain.
;;
;; Straight.el uses `url-retrieve-synchronously' here:
;; https://github.com/raxod502/straight.el#getting-started
;;
;; See:
;; (find-node "(url)Retrieving URLs")
;; (find-node "(url)Retrieving URLs" "url-retrieve-synchronously")
;; (find-node "(url)Dealing with HTTP documents")
;; (find-es "emacs" "url-retrieve")
;; (find-es "emacs" "find-urlretrieve")
;; https://lists.gnu.org/archive/html/help-gnu-emacs/2021-10/msg00060.html
;;
;; This file contains some functions for PLAYING with
;; `url-retrieve-synchronously'. This is unreliable code.
;; You have been warned.
;;
;; (load (buffer-file-name))
(defvar ee-urlretrieve-headers ""
"The HTTP headers returned by the last call to `find-urlretrieve'.")
(defun find-urlretrieve00 (url)
"An internal function used by `find-urlretrieve'."
(find-ebuffer
(url-retrieve-synchronously url 'silent 'inhibit-cookies)
"\n\n"))
(defun ee-urlretrieve0 (url)
"Use `url-retrieve-synchronously' to download URL.
When `url-retrieve-synchronously' is used for http or http it
returns a buffer containing the response headers, then a blank
line, then the contents (the \"message body\"). This function
saves the response headers in the variable
`ee-urlretrieve-headers', returns the message body, and deletes
the buffer.\n
This function doesn't perform any error checking and is as
simplistic as possible. Use it only to experiment with
`url-retrieve-synchronously'."
(find-urlretrieve00 url)
(setq ee-urlretrieve-headers
(buffer-substring (point-min) (- (point) 2)))
(prog1 (buffer-substring (point) (point-max))
(kill-buffer (current-buffer))))
(setq ee-straight-url
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el")
;; Tests:
;; (find-urlretrieve00 ee-straight-url)
;; (find-estring-elisp (ee-urlretrieve0 ee-straight-url))
;; (find-urlretrieve00 "http://foo/bar")
;; (find-urlretrieve00 "http://angg.twu.net/")
;; (find-urlretrieve00 "http://angg.twu.net/doesnotexist")
;; Local Variables:
;; coding: utf-8-unix
;; End: