branch: elpa/hyperdrive
commit d4d3d92e17d288e5ff62b53f7843378797f2ee9f
Author: Joseph Turner <[email protected]>
Commit: Joseph Turner <[email protected]>
Refactor: (h/fill-metadata) Don't use :as
This allows us to access the response headers.
---
hyperdrive-lib.el | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 7a0704b1fc..20c2a85046 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -967,14 +967,17 @@ HYPERDRIVE's public metadata file."
;; NOTE: Don't attempt to fill hyperdrive struct with old
metadata
:version nil))
(metadata (condition-case err
- (h/api 'get (he/url entry)
- :as (lambda ()
- (condition-case nil
- (json-read)
- (json-error
- (h/message "Error parsing JSON metadata file:
%s"
- (he/url entry)))))
- :noquery t)
+ ;; TODO: Refactor to use :as 'response-with-buffer and
call h/fill
+ (pcase-let
+ (((cl-struct plz-response headers body)
+ (h/api 'get (he/url entry) :as 'response :noquery
t)))
+ (with-temp-buffer
+ (insert body)
+ (goto-char (point-min))
+ (json-read)))
+ (json-error
+ (h/message "Error parsing JSON metadata file: %s"
+ (he/url entry)))
(plz-error
(pcase (plz-response-status (plz-error-response (caddr
err)))
;; FIXME: If plz-error is a curl-error, this block will
fail.