Function: eca--curl-download-string

eca--curl-download-string is a natively compiled function defined in eca-process.el.

Signature

(eca--curl-download-string URL)

Documentation

Download content from URL as a string, shelling out to curl.

Bounded by eca-server-fetch-timeout seconds and retried up to eca-server-fetch-retries times so an unreachable GitHub cannot hang Emacs. Signals an error when the download fails.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-process.el
(defun eca--curl-download-string (url)
  "Download content from URL as a string, shelling out to curl.
Bounded by `eca-server-fetch-timeout' seconds and retried up to
`eca-server-fetch-retries' times so an unreachable GitHub cannot
hang Emacs.  Signals an error when the download fails."
  (let ((curl-cmd (or (executable-find "curl")
                      (executable-find "curl.exe"))))
    (unless curl-cmd
      (error "Curl not found. Please install curl or customize eca-custom-command"))
    (with-temp-buffer
      (let ((exit-code (call-process curl-cmd nil (list (current-buffer) nil) nil
                                     "-L" "-s" "-f"
                                     "--max-time" (number-to-string eca-server-fetch-timeout)
                                     "--retry" (number-to-string eca-server-fetch-retries)
                                     url)))
        (unless (and (numberp exit-code) (zerop exit-code))
          (error "Curl failed to download from %s (exit %s)" url exit-code))
        (when (zerop (buffer-size))
          (error "Curl returned an empty response from %s" url))
        (buffer-string)))))