   (forward-line 1)
   (string-to-number (match-string 1)))
 
+(defun elfeed-curl--adjust-location (old-url new-url)
+  "Return full URL for maybe-relative NEW-URL from full URL old-url."
+  (let ((old (url-generic-parse-url old-url))
+        (new (url-generic-parse-url new-url)))
+    (cond
+     ;; Is new URL absolute already?
+     ((url-type new) new-url)
+     ;; Does it start with //? Append the old protocol.
+     ((url-fullness new) (concat (url-type old) new-url))
+     ;; Is it a relative path?
+     ((not (string-match-p "^/" new-url))
+      (let* ((old-dir (or (file-name-directory (url-filename old)) "/"))
+             (new-file (concat old-dir new-url)))
+        (setf (url-filename old) nil
+              (url-target old) nil
+              (url-attributes old) nil
+              (url-filename old) new-file)
+        (url-recreate-url old)))
+     ;; Replace the relative part.
+     ((progn
+        (setf (url-filename old) new-url
+              (url-target old) nil
+              (url-attributes old) nil)
+        (url-recreate-url old))))))
+
 (defun elfeed-curl--parse-http ()
   "Parse HTTP headers, setting the appropriate local variables."
   (setf elfeed-curl-status-code nil)


(defvar-local elfeed-curl-error-message nil
  "Human-friendly message describing the error.")

(defvar elfeed-curl--error-codes
  '((1 . "Unsupported protocol.")

;; * `elfeed-curl-retrieve-synchronously'
;; * `elfeed-curl-enqueue'

;; And has four buffer-local variables for use in callbacks:

;; * `elfeed-curl-headers'
;; * `elfeed-curl-status-code'
;; * `elfeed-curl-error-message'
;; * `elfeed-curl-location'

;;; Code:

