aboutsummaryrefslogtreecommitdiff
path: root/buildbot-utils.el
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2023-03-26 10:29:18 +1100
committerYuchen Pei <hi@ypei.me>2023-03-26 10:29:18 +1100
commita7e313d116b059b23ddb6efa185e3606f1da75a8 (patch)
tree06144ba9547d0f7ee3778ff1f1d0085699945106 /buildbot-utils.el
parent20fd138b70a92fa3dc8a8a44e95fa2be57da092f (diff)
add logs formatting and cache
Diffstat (limited to 'buildbot-utils.el')
-rw-r--r--buildbot-utils.el28
1 files changed, 27 insertions, 1 deletions
diff --git a/buildbot-utils.el b/buildbot-utils.el
index 3d4a901..d3b4a1e 100644
--- a/buildbot-utils.el
+++ b/buildbot-utils.el
@@ -41,9 +41,35 @@
(json-read)))
(error "HTTP error: %s" (buffer-substring (point) (point-max)))))))
+(defun buildbot-url-fetch-raw (url &optional decompression with-header)
+ (with-current-buffer (get-buffer-create buildbot-client-buffer-name)
+ (goto-char (point-max))
+ (insert "[" (current-time-string) "] Request: " url "\n"))
+ (with-current-buffer (url-retrieve-synchronously url t)
+ (let ((header) (status) (fields))
+ (buildbot-delete-http-header)
+ (goto-char (point-min))
+ (setq header (buildbot-parse-http-header (car kill-ring))
+ status (alist-get 'status header)
+ fields (alist-get 'fields header))
+ (with-current-buffer buildbot-client-buffer-name
+ (insert "[" (current-time-string) "] Response: " status "\n"))
+ (when decompression
+ (call-process-region (point) (point-max) "gunzip" t t t)
+ (goto-char (point-min)))
+ (call-interactively 'delete-trailing-whitespace)
+ (if (string= status "200")
+ (unless (= (point) (point-max))
+ (if with-header
+ (list
+ (cons 'header fields)
+ (cons 'json (buffer-string)))
+ (buffer-string)))
+ (error "HTTP error: %s" (buffer-substring (point) (point-max)))))))
+
(defun buildbot-format-attr (attr)
(string-join (mapcar (lambda (pair)
- (format "%s=%s" (car pair) (cdr pair)))
+ (format "%s=%s" (car pair) (cdr pair)))
attr)
"&"))