diff options
Diffstat (limited to 'buildbot-utils.el')
-rw-r--r-- | buildbot-utils.el | 28 |
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) "&")) |