Function: package--with-response-buffer-1
package--with-response-buffer-1 is a byte-compiled function defined in
package.el.gz.
Signature
(package--with-response-buffer-1 URL BODY &key ASYNC FILE ERROR-FUNCTION NOERROR &allow-other-keys)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/package.el.gz
(cl-defun package--with-response-buffer-1 (url body &key async file error-function noerror &allow-other-keys)
(if (string-match-p "\\`https?:" url)
(let ((url (url-expand-file-name file url)))
(if async
(package--unless-error #'ignore
(url-retrieve
url
(lambda (status)
(let ((b (current-buffer)))
(require 'url-handlers)
(package--unless-error body
(when-let* ((er (plist-get status :error)))
(error "Error retrieving: %s %S" url er))
(with-current-buffer b
(goto-char (point-min))
(unless (search-forward-regexp "^\r?\n\r?" nil t)
(error "Error retrieving: %s %S"
url "incomprehensible buffer")))
(url-insert b)
(kill-buffer b)
(goto-char (point-min)))))
nil
'silent))
(package--unless-error body
;; Copy&pasted from url-insert-file-contents,
;; except it calls `url-insert' because we want the contents
;; literally (but there's no url-insert-file-contents-literally).
(let ((buffer (url-retrieve-synchronously url)))
(unless buffer (signal 'file-error (list url "No Data")))
(when (fboundp 'url-http--insert-file-helper)
;; XXX: This is HTTP/S specific and should be moved
;; to url-http instead. See bug#17549.
(url-http--insert-file-helper buffer url))
(url-insert buffer)
(kill-buffer buffer)
(goto-char (point-min))))))
(package--unless-error body
(unless (file-name-absolute-p url)
(error "Location %s is not a url nor an absolute file name" url))
(insert-file-contents-literally (expand-file-name file url)))))