;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\210\307\310\311\312\313\314\315\316&\207" [require cl-lib url mail-utils autorevert auth-source mailheader custom-declare-group request nil "Compatible layer for URL request in Emacs." :group comm :prefix "request-"] 8) (defconst request-version "0.3.3") (byte-code "\300\301\302\303\304DD\305\306\307%\210\300\310\302\303\311DD\312\306\313%\210\300\314\302\303\315DD\316\306\317%\210\300\320\302\303\321DD\322\306\323%\210\300\324\302\303\325DD\326\306\327%\210\330\331\332\333#\210\300\334\302\303\335DD\336\306\337%\210\300\340\302\303\341DD\342\306\343%\207" [custom-declare-variable request-storage-directory funcall function #[0 "\301!\302P\207" [user-emacs-directory file-name-as-directory "request"] 2] "Directory to store data related to request.el." :type directory request-curl #[0 "\300\207" [#1="curl"] 1 #1#] "Executable for curl command." string request-curl-options #[0 "\300\207" [nil] 1] "List of curl command options.\n\nList of strings that will be passed to every curl invocation.\nYou can pass extra options here, like setting the proxy." (repeat string) request-backend #[0 "\301!\203\302\207\303\207" [request-curl executable-find curl url-retrieve] 2] "Backend to be used for HTTP request.\nAutomatically set to `curl' if curl command is found." (choice (const :tag "cURL backend" curl) (const :tag "url-retrieve backend" url-retrieve)) request-timeout #[0 "\300\207" [nil] 1] "Default request timeout in second.\nnil means no timeout." (choice (integer :tag "Request timeout seconds") (boolean :tag "No timeout" nil)) make-obsolete-variable request-temp-prefix nil "0.3.3" request-log-level #[0 "\300\207" [-1] 1] "Logging level for request.\nOne of `error'/`warn'/`info'/`verbose'/`debug'/`trace'/`blather'.\n-1 means no logging." (choice (integer :tag "No logging" -1) (const :tag "Level error" error) (const :tag "Level warn" warn) (const :tag "Level info" info) (const :tag "Level Verbose" verbose) (const :tag "Level DEBUG" debug) (const :tag "Level TRACE" trace) (const :tag "Level BLATHER" blather)) request-message-level #[0 "\300\207" [warn] 1] "Logging level for request.\nSee `request-log-level'." (choice (integer :tag "No logging" -1) (const :tag "Level error" error) (const :tag "Level warn" warn) (const :tag "Level info" info) (const :tag "Level Verbose" verbose) (const :tag "Level DEBUG" debug) (const :tag "Level TRACE" trace) (const :tag "Level BLATHER" blather))] 6) #@98 Document FUNCTION with DOCSTRING. Use this for defstruct accessor etc. (fn FUNCTION DOCSTRING) (defalias 'request--document-function '(macro . #[514 "\300\301D\302F\207" [put quote 'function-documentation] 6 (#$ . 2593)])) (byte-code "\300\301\302\303#\300\301\304\305#\300\207" [function-put request--document-function lisp-indent-function defun doc-string-elt 2] 5) #@23 Named logging levels. (defconst request--log-level-def '((blather . 60) (trace . 50) (debug . 40) (verbose . 30) (info . 20) (warn . 10) (error . 0)) (#$ . 2971)) (defvar request-log-buffer-name " *request-log*") #@85 Main logging function at warning LEVEL in FMT with ARGS. (fn LEVEL FMT &rest ARGS) (defalias 'request-log '(macro . #[642 "\300\301\302\303\304DD\305B\306\307\302\310\311\312\f\311  BBFDC\313BBEEE\207" [cl-flet ((log-level-as-int (level) (if (integerp level) level (or (cdr (assq level request--log-level-def)) 0)))) let level log-level-as-int ((log-level (log-level-as-int request-log-level)) (msg-level (log-level-as-int request-message-level))) when (<= level (max log-level msg-level)) msg format "[%s] %s" ((when (<= level log-level) (with-current-buffer (get-buffer-create request-log-buffer-name) (setq buffer-read-only t) (let ((inhibit-read-only t)) (goto-char (point-max)) (insert msg "\n")))) (when (<= level msg-level) (message "%s" msg)))] 17 (#$ . 3190)])) (byte-code "\300\301\302\303#\300\207" [function-put request-log lisp-indent-function 1] 4) #@162 `url-unreserved-chars' copied from Emacs 24.3 release candidate. This is used for making `request--urlencode-alist' RFC 3986 compliant for older Emacs versions. (defconst request--url-unreserved-chars '(97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 48 49 50 51 52 53 54 55 56 57 45 95 46 126) (#$ . 4066)) #@55 Hexify ALIST fields according to RFC3986. (fn ALIST) (defalias 'request--urlencode-alist #[257 "\302\302\211\303\304\211\203\303\202\305\262:\203O@\262\211A\262\242\262P\262\306\307\310\"!P\262\311P\262\306\307\310\"!P\262A\262\302\262\202\266\206)\207" [request--url-unreserved-chars url-unreserved-chars nil "" t "&" url-hexify-string format "%s" "="] 12 (#$ . 4511)]) #@56 Parse the first header line such as "HTTP/1.1 200 OK". (defalias 'request--parse-response-at-point #[0 "\300\301\302\303#\205\304\305\306!\307\310\305\311!!F\207" [re-search-forward "\\=[ \n]*HTTP/\\([0-9\\.]+\\) +\\([0-9]+\\)" nil t :version match-string 1 :code string-to-number 2] 6 (#$ . 4924)]) #@86 Scan forward to next blank line allowing NOERROR if missing. (fn &optional NOERROR) (defalias 'request--goto-next-body #[256 "\300\301\302#\207" [re-search-forward "^ \n" nil] 5 (#$ . 5233)]) #@75 compiler-macro for inlining `request-response-p'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-p--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-p (and (memq (type-of cl-x) cl-struct-request-response-tags) t)) nil] 9 (#$ . 5433)]) (put 'request-response-p 'compiler-macro 'request-response-p--cmacro) #@13 (fn CL-X) (defalias 'request-response-p #[257 "\301!>\205 \302\207" [cl-struct-request-response-tags type-of t] 3 (#$ . 5803)]) (byte-code "\300\301\302\303#\304\305\306\301#\207" [function-put request-response-p side-effect-free error-free put request-response cl-deftype-satisfies] 5) #@85 compiler-macro for inlining `request-response-status-code'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-status-code--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-status-code (progn (aref cl-x 1))) nil] 9 (#$ . 6101)]) (put 'request-response-status-code 'compiler-macro 'request-response-status-code--cmacro) #@73 Access slot "status-code" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response-status-code #[257 "\211\300H\207" [1] 3 (#$ . 6481)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response-status-code side-effect-free t] 4) #@81 compiler-macro for inlining `request-response-history'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-history--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-history (progn (aref cl-x 2))) nil] 9 (#$ . 6746)]) (put 'request-response-history 'compiler-macro 'request-response-history--cmacro) #@69 Access slot "history" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response-history #[257 "\211\300H\207" [2] 3 (#$ . 7106)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response-history side-effect-free t] 4) #@78 compiler-macro for inlining `request-response-data'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-data--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-data (progn (aref cl-x 3))) nil] 9 (#$ . 7359)]) (put 'request-response-data 'compiler-macro 'request-response-data--cmacro) #@66 Access slot "data" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response-data #[257 "\211\300H\207" [3] 3 (#$ . 7704)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response-data side-effect-free t] 4) #@86 compiler-macro for inlining `request-response-error-thrown'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-error-thrown--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-error-thrown (progn (aref cl-x 4))) nil] 9 (#$ . 7948)]) (put 'request-response-error-thrown 'compiler-macro 'request-response-error-thrown--cmacro) #@74 Access slot "error-thrown" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response-error-thrown #[257 "\211\300H\207" [4] 3 (#$ . 8333)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response-error-thrown side-effect-free t] 4) #@87 compiler-macro for inlining `request-response-symbol-status'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-symbol-status--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-symbol-status (progn (aref cl-x 5))) nil] 9 (#$ . 8601)]) (put 'request-response-symbol-status 'compiler-macro 'request-response-symbol-status--cmacro) #@75 Access slot "symbol-status" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response-symbol-status #[257 "\211\300H\207" [5] 3 (#$ . 8991)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response-symbol-status side-effect-free t] 4) #@77 compiler-macro for inlining `request-response-url'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-url--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-url (progn (aref cl-x 6))) nil] 9 (#$ . 9262)]) (put 'request-response-url 'compiler-macro 'request-response-url--cmacro) #@65 Access slot "url" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response-url #[257 "\211\300H\207" [6] 3 (#$ . 9602)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response-url side-effect-free t] 4) #@80 compiler-macro for inlining `request-response-done-p'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-done-p--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-done-p (progn (aref cl-x 7))) nil] 9 (#$ . 9843)]) (put 'request-response-done-p 'compiler-macro 'request-response-done-p--cmacro) #@68 Access slot "done-p" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response-done-p #[257 "\211\300H\207" [7] 3 (#$ . 10198)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response-done-p side-effect-free t] 4) #@82 compiler-macro for inlining `request-response-settings'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response-settings--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response-settings (progn (aref cl-x 8))) nil] 9 (#$ . 10449)]) (put 'request-response-settings 'compiler-macro 'request-response-settings--cmacro) #@70 Access slot "settings" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response-settings #[257 "\211\300H\207" [8] 3 (#$ . 10815)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response-settings side-effect-free t] 4) #@81 compiler-macro for inlining `request-response--buffer'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response--buffer--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response--buffer (progn (aref cl-x 9))) nil] 9 (#$ . 11072)]) (put 'request-response--buffer 'compiler-macro 'request-response--buffer--cmacro) #@69 Access slot "-buffer" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response--buffer #[257 "\211\300H\207" [9] 3 (#$ . 11433)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response--buffer side-effect-free t] 4) #@85 compiler-macro for inlining `request-response--raw-header'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response--raw-header--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response--raw-header (progn (aref cl-x 10))) nil] 9 (#$ . 11687)]) (put 'request-response--raw-header 'compiler-macro 'request-response--raw-header--cmacro) #@73 Access slot "-raw-header" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response--raw-header #[257 "\211\300H\207" [10] 3 (#$ . 12069)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response--raw-header side-effect-free t] 4) #@80 compiler-macro for inlining `request-response--timer'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response--timer--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response--timer (progn (aref cl-x 11))) nil] 9 (#$ . 12336)]) (put 'request-response--timer 'compiler-macro 'request-response--timer--cmacro) #@68 Access slot "-timer" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response--timer #[257 "\211\300H\207" [11] 3 (#$ . 12693)]) (byte-code "\300\301\302\303#\300\207" [function-put request-response--timer side-effect-free t] 4) #@82 compiler-macro for inlining `request-response--backend'. (fn CL-WHOLE-ARG CL-X) (defalias 'request-response--backend--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block request-response--backend (progn (aref cl-x 12))) nil] 9 (#$ . 12945)]) (put 'request-response--backend 'compiler-macro 'request-response--backend--cmacro) #@70 Access slot "-backend" of `request-response' struct CL-X. (fn CL-X) (defalias 'request-response--backend #[257 "\211\300H\207" [12] 3 (#$ . 13312)]) (byte-code "\300\301\302\303#\304\305\306\"\207" [function-put request-response--backend side-effect-free t defalias copy-request-response copy-sequence] 4) #@192 compiler-macro for inlining `make-request-response'. (fn CL-WHOLE &cl-quote &key STATUS-CODE HISTORY DATA ERROR-THROWN SYMBOL-STATUS URL DONE-P SETTINGS -BUFFER -RAW-HEADER -TIMER -BACKEND) (defalias 'make-request-response--cmacro #[385 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\300\305\"A@\300\306\"A@\300\307\"A@\300\310\"A@\300 \311\"A@\300\n\312\"A@\300 \313\"A@\300\f\314\"A@\315\316\317\320\320&\207" [plist-member :status-code :history :data :error-thrown :symbol-status :url :done-p :settings :-buffer :-raw-header :-timer :-backend cl--defsubst-expand (status-code history data error-thrown symbol-status url done-p settings -buffer -raw-header -timer -backend) (cl-block make-request-response (record 'request-response status-code history data error-thrown symbol-status url done-p settings -buffer -raw-header -timer -backend)) nil] 32 (#$ . 13626)]) (put 'make-request-response 'compiler-macro 'make-request-response--cmacro) #@172 Constructor for objects of type `request-response'. (fn &key STATUS-CODE HISTORY DATA ERROR-THROWN SYMBOL-STATUS URL DONE-P SETTINGS -BUFFER -RAW-HEADER -TIMER -BACKEND) (defalias 'make-request-response #[128 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\300\305\"A@\300\306\"A@\300\307\"A@\300\310\"A@\300 \311\"A@\300\n\312\"A@\300 \313\"A@\300\f\314\"A@\315\316            & \207" [plist-member :status-code :history :data :error-thrown :symbol-status :url :done-p :settings :-buffer :-raw-header :-timer :-backend record request-response] 27 (#$ . 14622)]) (byte-code "\300\301\302\303#\304\305\306\307\310\311\312\313\305\303& \207" [function-put make-request-response side-effect-free t cl-struct-define request-response "A structure holding all relevant information of a request." cl-structure-object record nil ((cl-tag-slot) (status-code) (history) (data) (error-thrown) (symbol-status) (url) (done-p) (settings) (-buffer) (-raw-header) (-timer) (-backend)) cl-struct-request-response-tags] 11) #@84 Append to FUNCTION's DOCSTRING some more canned verbiage. (fn FUNCTION DOCSTRING) (defalias 'request--document-response '(macro . #[514 "\300\301PE\207" [request--document-function "\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)"] 6 (#$ . 15664)])) (byte-code "\300\301\302\303#\300\301\304\305#\306\307\310\311#\210\306\312\310\313#\210\306\314\310\315#\210\306\316\310\317#\210\306\320\310\321#\210\306\322\310\323#\210\306\324\310\325#\210\306\326\310\327#\207" [function-put request--document-response lisp-indent-function defun doc-string-elt 2 put request-response-status-code function-documentation "Integer HTTP response code (e.g., 200).\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)" request-response-history "Redirection history (a list of response object).\nThe first element is the oldest redirection.\n\nYou can use restricted portion of functions for the response\nobjects in the history slot. It also depends on backend. Here\nis the table showing what functions you can use for the response\nobjects in the history slot.\n\n==================================== ============== ==============\nSlots Backends\n------------------------------------ -----------------------------\n\\ curl url-retrieve\n==================================== ============== ==============\nrequest-response-url yes yes\nrequest-response-header yes no\nother functions no no\n==================================== ============== ==============\n\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)" request-response-data "Response parsed by the given parser.\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)" request-response-error-thrown "Error thrown during request.\nIt takes the form of ``(ERROR-SYMBOL . DATA)``, which can be\nre-raised (`signal'ed) by ``(signal ERROR-SYMBOL DATA)``.\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)" request-response-symbol-status "A symbol representing the status of request (not HTTP response code).\nOne of success/error/timeout/abort/parse-error.\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)" request-response-url "Final URL location of response.\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)" request-response-done-p "Return t when the request is finished or aborted.\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)" request-response-settings "Keyword arguments passed to `request' function.\nSome arguments such as HEADERS is changed to the one actually\npassed to the backend. Also, it has additional keywords such\nas URL which is the requested URL.\n\n.. This is an accessor for `request-response' object.\n\n(fn RESPONSE)"] 6) #@416 Fetch the values of RESPONSE header field named FIELD-NAME. It returns comma separated values when the header has multiple field with the same name, as :RFC:`2616` specifies. Examples:: (request-response-header response "content-type") ; => "text/html; charset=utf-8" (request-response-header response "unknown-field") ; => nil (fn RESPONSE FIELD-NAME) (defalias 'request-response-header #[514 "\300H\211\205\"\301\302\303\"r\211q\210\304\305\"\216\306 \210c\210\307\310\303#*\262\207" [10 generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] erase-buffer mail-fetch-field nil] 8 (#$ . 18629)]) #@263 Return RESPONSE headers as an alist. I would have chosen a function name that wasn't so suggestive that `headers` is a member of the `request-response` struct, but as there's already precedent with `request-response-header', I hew to consistency. (fn RESPONSE) (defalias 'request-response-headers #[257 "\211\300H\211\205(\301\302\303\"r\211q\210\304\305\"\216\212c\210)\212\306 )\203#\307y\210\310 *\262\207" [10 generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] request--parse-response-at-point nil mail-header-extract-no-properties] 6 (#$ . 19358)]) #@388 Map backend and method name to actual method (symbol). It's alist of alist, of the following form:: ((BACKEND . ((METHOD . FUNCTION) ...)) ...) It would be nicer if I can use EIEIO. But as CEDET is included in Emacs by 23.2, using EIEIO means abandon older Emacs versions. It is probably necessary if I need to support more backends. But let's stick to manual dispatch for now. (defconst request--backend-alist '((url-retrieve (request . request--url-retrieve) (request-sync . request--url-retrieve-sync) (terminate-process . delete-process) (get-cookies . request--url-retrieve-get-cookies)) (curl (request . request--curl) (request-sync . request--curl-sync) (terminate-process . interrupt-process) (get-cookies . request--curl-get-cookies))) (#$ . 19986)) #@82 Return `fucall'able object for METHOD of current `request-backend'. (fn METHOD) (defalias 'request--choose-backend #[257 "\302\302 \"\206 \303\304\"\"\207" [request-backend request--backend-alist assoc-default error "%S is not valid `request-backend'"] 6 (#$ . 20760)]) #@194 Lookup HOST LOCALPART SECURE in cookie jar as`document.cookie` string. Example:: (request-cookie-string "127.0.0.1" "/") ; => "key=value; key2=value2" (fn HOST &optional LOCALPART SECURE) (defalias 'request-cookie-string #[769 "\300\301\302#\303#\207" [mapconcat #[257 "\211@\300AQ\207" ["="] 4 "\n\n(fn NV)"] request-cookie-alist "; "] 9 (#$ . 21042)]) #@175 Lookup HOST LOCALPART SECURE in cookie jar as alist. Example:: (request-cookie-alist "127.0.0.1" "/") ; => (("key" . "value") ...) (fn HOST &optional LOCALPART SECURE) (defalias 'request-cookie-alist #[769 "\300\301!#\207" [request--choose-backend get-cookies] 7 (#$ . 21412)]) #@5958 Main entry requesting URL with property list SETTINGS as follow. ==================== ======================================================== Keyword argument Explanation ==================== ======================================================== TYPE (string) type of request to make: POST/GET/PUT/DELETE PARAMS (alist) set "?key=val" part in URL DATA (string/alist) data to be sent to the server FILES (alist) files to be sent to the server (see below) PARSER (symbol) a function that reads current buffer and return data HEADERS (alist) additional headers to send with the request ENCODING (symbol) encoding for request body (utf-8 by default) SUCCESS (function) called on success ERROR (function) called on error COMPLETE (function) called on both success and error TIMEOUT (number) timeout in second STATUS-CODE (alist) map status code (int) to callback SYNC (bool) If non-nil, wait until request is done. Default is nil. ==================== ======================================================== * Callback functions Callback functions STATUS, ERROR, COMPLETE and `cdr's in element of the alist STATUS-CODE take same keyword arguments listed below. For forward compatibility, these functions must ignore unused keyword arguments (i.e., it's better to use `&allow-other-keys' [#]_).:: (CALLBACK ; SUCCESS/ERROR/COMPLETE/STATUS-CODE :data data ; whatever PARSER function returns, or nil :error-thrown error-thrown ; (ERROR-SYMBOL . DATA), or nil :symbol-status symbol-status ; success/error/timeout/abort/parse-error :response response ; request-response object ...) .. [#] `&allow-other-keys' is a special "markers" available in macros in the CL library for function definition such as `cl-defun' and `cl-function'. Without this marker, you need to specify all arguments to be passed. This becomes problem when request.el adds new arguments when calling callback functions. If you use `&allow-other-keys' (or manually ignore other arguments), your code is free from this problem. See info node `(cl) Argument Lists' for more information. Arguments data, error-thrown, symbol-status can be accessed by `request-response-data', `request-response-error-thrown', `request-response-symbol-status' accessors, i.e.:: (request-response-data RESPONSE) ; same as data Response object holds other information which can be accessed by the following accessors: `request-response-status-code', `request-response-url' and `request-response-settings' * STATUS-CODE callback STATUS-CODE is an alist of the following format:: ((N-1 . CALLBACK-1) (N-2 . CALLBACK-2) ...) Here, N-1, N-2,... are integer status codes such as 200. * FILES FILES is an alist of the following format:: ((NAME-1 . FILE-1) (NAME-2 . FILE-2) ...) where FILE-N is a list of the form:: (FILENAME &key PATH BUFFER STRING MIME-TYPE) FILE-N can also be a string (path to the file) or a buffer object. In that case, FILENAME is set to the file name or buffer name. Example FILES argument:: `(("passwd" . "/etc/passwd") ; filename = passwd ("scratch" . ,(get-buffer "*scratch*")) ; filename = *scratch* ("passwd2" . ("password.txt" :file "/etc/passwd")) ("scratch2" . ("scratch.txt" :buffer ,(get-buffer "*scratch*"))) ("data" . ("data.csv" :data "1,2,3\n4,5,6\n"))) .. note:: FILES is implemented only for curl backend for now. As furl.el_ supports multipart POST, it should be possible to support FILES in pure elisp by making furl.el_ another backend. Contributions are welcome. .. _furl.el: https://code.google.com/p/furl-el/ * PARSER function PARSER function takes no argument and it is executed in the buffer with HTTP response body. The current position in the HTTP response buffer is at the beginning of the buffer. As the HTTP header is stripped off, the cursor is actually at the beginning of the response body. So, for example, you can pass `json-read' to parse JSON object in the buffer. To fetch whole response as a string, pass `buffer-string'. When using `json-read', it is useful to know that the returned type can be modified by `json-object-type', `json-array-type', `json-key-type', `json-false' and `json-null'. See docstring of each function for what it does. For example, to convert JSON objects to plist instead of alist, wrap `json-read' by `lambda' like this.:: (request "https://..." :parser (lambda () (let ((json-object-type 'plist)) (json-read))) ...) This is analogous to the `dataType' argument of jQuery.ajax_. Only this function can access to the process buffer, which is killed immediately after the execution of this function. * SYNC Synchronous request is functional, but *please* don't use it other than testing or debugging. Emacs users have better things to do rather than waiting for HTTP request. If you want a better way to write callback chains, use `request-deferred'. If you can't avoid using it (e.g., you are inside of some hook which must return some value), make sure to set TIMEOUT to relatively small value. Due to limitation of `url-retrieve-synchronously', response slots `request-response-error-thrown', `request-response-history' and `request-response-url' are unknown (always nil) when using synchronous request with `url-retrieve' backend. * Note API of `request' is somewhat mixture of jQuery.ajax_ (Javascript) and requests.request_ (Python). .. _jQuery.ajax: https://api.jquery.com/jQuery.ajax/ .. _requests.request: https://docs.python-requests.org (fn URL &rest SETTINGS &key (PARAMS nil) (DATA nil) (HEADERS nil) (ENCODING \='utf-8) (ERROR nil) (SYNC nil) (RESPONSE (make-request-response)) &allow-other-keys) (defalias 'request #[385 "C\302\303\"A@\302\304\"A@\302\305\"A@\302\306\"\206\307A@\302\310\"A@\302\311\"A@\302\312\"\206F\313\314\315\313\211\211\211\211\211\211\211\211\211\211\211& DA@\204[\316\317 \"\262\320 \310#\262 ;\204|\203|\321\322\323#\204|\324!\262\320 \304#\262 \203\243\211\242\325\n\242\313\323\326#)\266\203\203\233\327\202\234\330\324\n!Q\240\210\320 \331\n\242#\262 \320 \312#\262 \320 \306#\262 \211\211\332 I\266\211\211\333\n\242I\266\211\211\334 I\266\335\203\341\336\337!\202\344\336\340! \242 #\210\207" [inhibit-changing-match-data request-backend plist-member :params :data :headers :encoding (nil utf-8) :error :sync :response nil record request-response make-closure #[128 "\306\307\"A@\310\211\311! !\n!]X\205H\312\313\311\312\314\300\242\n##X\203<r\315 !q\210\316\211db\210\211\317\261\210*X\205F\320\321\"\262\207" [V0 request-log-level request-message-level request-log-buffer-name buffer-read-only inhibit-read-only plist-member :symbol-status #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] error format "[%s] %s" "request-default-error-callback: %s %s" get-buffer-create t "\n" message "%s"] 14 "\n\n(fn &rest ARGS &key SYMBOL-STATUS &allow-other-keys)"] plist-put assoc-string "Content-Type" t request--urlencode-alist "\\?" string-match "&" "?" :url 8 6 12 apply request--choose-backend request-sync request] 24 (#$ . 21707)]) (byte-code "\300\301\302\303#\300\207" [function-put request lisp-indent-function defun] 4) #@69 Strip off carriage return in the header of RESPONSE. (fn RESPONSE) (defalias 'request--clean-header #[257 "\211\305H\306H\211\307=\203\310\202\311\312!\205\216rq\210eb\210\313\314\315#\205\215\316\317!\320\232?\205\215\321\211\322!! !]X\203|\323\324\322\323\325\212\326y\210\327 )\212\330y\210\331 ){\"#X\203pr\332\n!q\210\315\211db\210\211\333\261\210*X\203{\334\335\"\210\210\266\336\337e\315#\205\215\340\320!\210\202~)\207" [request-log-level request-message-level request-log-buffer-name buffer-read-only inhibit-read-only 9 12 url-retrieve "^ ?$" "^ $" buffer-live-p re-search-forward nil t match-string 0 "" #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] trace format "[%s] %s" "request--clean-header: cleaning\n%s" -1 line-beginning-position 1 line-end-position get-buffer-create "\n" message "%s" re-search-backward " $" replace-match] 16 (#$ . 29258)]) #@75 Move the header to the raw-header slot of RESPONSE object. (fn RESPONSE) (defalias 'request--cut-header #[257 "\211\305H\306!\205nr\211q\210eb\210\307\310\311\312#\205m\211\313e`{I\266\314\211\315!! !]X\203e\316\317\315\316\320e`Td^{\"#X\203Yr\321\n!q\210\312\211db\210\211\322\261\210*X\203d\323\324\"\210\210\266e`Td^|)\207" [request-log-level request-message-level request-log-buffer-name buffer-read-only inhibit-read-only 9 buffer-live-p re-search-forward "^$" nil t 10 #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] trace format "[%s] %s" "request--cut-header: cutting\n%s" get-buffer-create "\n" message "%s"] 15 (#$ . 30210)]) #@48 Return FILE as the local file name. (fn FILE) (defalias 'request-untrampify-filename #[257 "\300\301\"\206\211\207" [file-remote-p localname] 4 (#$ . 30926)]) #@94 In RESPONSE buffer, decode via ENCODING, then send to PARSER. (fn RESPONSE ENCODING PARSER) (defalias 'request--parse-data #[771 "\305H\306!\205tr\211q\210\307\211\310!! !]X\203M\311\312\310\311\313\314 \"#X\203Ar\315\n!q\210\316\211db\210\211\317\261\210*X\203L\320\321\"\210\210\266\322H\323=?\205s\324ed\325$\210eb\210\211\326\203n \202p\314 I\262)\207" [request-log-level request-message-level request-log-buffer-name buffer-read-only inhibit-read-only 9 buffer-live-p #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] trace format "[%s] %s" "request--parse-data: %s" buffer-string get-buffer-create t "\n" message "%s" 1 204 recode-region no-conversion 3] 15 (#$ . 31095)]) #@56 Return non-nil if URL looks like a file URL. (fn URL) (defalias 'request-url-file-p #[257 "\211;\205\302!\303!>\204\304\305\306D\"\210\211\307H\262\211;\205/\310\311\312\313#)\266\203?\207" [cl-struct-url-tags inhibit-changing-match-data url-generic-parse-url type-of signal wrong-type-argument url 1 "^http" nil t string-match] 9 (#$ . 31859)]) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put request-url-file-p speed -1 put byte-optimizer byte-compile-inline-expand] 5) #@224 Parse BUFFER according to PARSER. Delegate to callbacks SUCCESS, ERROR, and COMPLETE the STATUS-CODE of RESPONSE via ENCODING. (fn BUFFER &key PARSER SUCCESS ERROR COMPLETE STATUS-CODE RESPONSE ENCODING &allow-other-keys) (defalias 'request--callback #[385 "\306\307\"A@\306\310\"A@\306\311\"A@\306\312\"A@\306\313\"A@\306\314\"A@\306\315\"A@\316\211\317!! !]X\203y\320\321\317\320\322\323!\205Rrq\210\324 )\"#X\203mr\325\n!q\210\326\211db\210\211\327\261\210*X\203x\330\331\"\210\210\266\211\332 I\266\333H\203\226\334\333H!\210\211\333\335I\266\336H\337H\340=\205\324\211\211;\205\276\341!\342! >\204\271\343\344\345D\"\210\211\346H\262\211;\205\322\347\335\326@\350#)\266\203?\266\202\211\204\340\351!\210\352!\210\266\3531\361\354 #0\210\202\355H\204\376\211\355I\266\356H?\205\f\211\356\357I\262\266\360 !\210\355H\203o\361\211\362!! !]X\203]\320\321\362\320\363\364 \355H!\"#X\203Qr\325\n!q\210\326\211db\210\211\327\261\210*X\203\\\330\331\"\210\210\266\356H\204\300\211\356\362I\266\202\300\356H\204|\211\356\365I\266\366\211\317!! !]X\203\276\320\321\317\320\367\n\370H\"#X\203\262r\325\n!q\210\326\211db\210\211\327\261\210*X\203\275\330\331\"\210\210\266\371\370H\372\356H\373\355H\314\257\356H\365=\211\203\340\202\342\203\352\374\202\353\375\2038\376\211\317!! !]X\203/\320\321\317\320\377 \"#X\203#r\325\n!q\210\326\211db\210\211\327\261\210*X\203.\330\331\"\210\210\266\201A\"\210\266\346H\236A\211\203\217\201B\211\317!! !]X\203\206\320\321\317\320\201C!#X\203zr\325\n!q\210\326\211db\210\211\327\261\210*X\203\205\330\331\"\210\210\266\201A\"\210\210\203\337\201D\211\317!! !]X\203\326\320\321\317\320\201E!#X\203\312r\325\n!q\210\326\211db\210\211\327\261\210*X\203\325\330\331\"\210\210\266\201A\"\210\210\211\201F\326I\207" [request-log-level request-message-level request-log-buffer-name buffer-read-only inhibit-read-only cl-struct-url-tags plist-member :parser :success :error :complete :status-code :response :encoding #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] debug format "[%s] %s" "request--callback: UNPARSED\n%s" buffer-live-p buffer-string get-buffer-create t "\n" message "%s" 9 11 cancel-timer nil 6 12 curl url-generic-parse-url type-of signal wrong-type-argument url 1 "^http" string-match request--clean-header request--cut-header (error) request--parse-data 4 5 parse-error kill-buffer #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] error "request--callback: %s" error-message-string success #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] "request--callback: PARSED\n%s" 3 :data :symbol-status :error-thrown "success" "error" #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] "request--callback: executing %s" inhibit-changing-match-data apply #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] "request--callback: executing status-code" #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] "request--callback: executing complete" 7] 24 (#$ . 32372)]) #@79 If RESPONSE times out, ensure `request--callback' gets called. (fn RESPONSE) (defalias 'request-response--timeout-callback #[257 "\211\211\300\301I\266\211\211\302\303I\266\211\304H\305!\205\306!\211\203$\307\310!!\207\311H?\205W\305!\203Hrq\210eb\210\312 )\313\314\"A@\211\315I\266\316\317\320H#\210\211\311\321I\262\207" [5 timeout 4 (error "Timeout") 9 buffer-live-p get-buffer-process request--choose-backend terminate-process 7 request--parse-response-at-point plist-member :code 1 apply request--callback 8 t] 9 (#$ . 35785)]) #@232 Abort request for RESPONSE (the object returned by `request'). Note that this function invoke ERROR and COMPLETE callbacks. Callbacks may not be called immediately but called later when associated process is exited. (fn RESPONSE) (defalias 'request-abort #[257 "\300\301H!\302H?\205%\211\302\303I\266\211\304\305I\266\306!\205%\307\310!!\207" [get-buffer-process 9 5 abort 7 t process-live-p request--choose-backend terminate-process] 6 (#$ . 36347)]) #@127 Augment SETTINGS with properties TYPE DATA FILES HEADERS. (fn &rest SETTINGS &key TYPE DATA FILES HEADERS &allow-other-keys) (defalias 'request--url-retrieve-preprocess-settings #[128 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\203 \305\306!\210\307\232\203>\203>\310\311\312#\204>\313B\262\314\304#\262\207" [plist-member :type :data :files :headers error "`url-retrieve' backend does not support FILES" "POST" assoc-string "Content-Type" t ("Content-Type" . "application/x-www-form-urlencoded") plist-put] 9 (#$ . 36817)]) #@333 Internal workhorse querying URL via curl. SETTINGS is a property list with keys (some optional) such as GET or POST TYPE, DATA for posting fields, TIMEOUT in seconds, RESPONSE a mandatory struct. HEADERS needs to be assigned after SETTINGS is preprocessed. (fn URL &rest SETTINGS &key TYPE DATA TIMEOUT RESPONSE &allow-other-keys) (defalias 'request--url-retrieve #[385 "\303\304\"A@\303\305\"A@\303\306\"A@\303\307\"A@\310\311\312\"\262\313\314\"\262\211\315\316\307D \244\317$\320!\321\"\210\211\322I\266\323\324#\210\325\310\"+\207" [url-request-extra-headers url-request-method url-request-data plist-member :type :data :timeout :response nil apply request--url-retrieve-preprocess-settings plist-get :headers url-retrieve request--url-retrieve-callback t get-buffer-process request--install-timeout 9 process-put :request-response set-process-query-on-exit-flag] 13 (#$ . 37374)]) #@232 Ensure `request--callback' gets called for STATUS. SETTINGS should include RESPONSE and URL properties which inform any necessary redirect or history recording logic. (fn STATUS &rest SETTINGS &key RESPONSE URL &allow-other-keys) (defalias 'request--url-retrieve-callback #[385 "\306\307\"A@\306\310\"A@\311\312!\203\211\313I\266\314\315\"\211\203(\211\316I\266\210\317\320\320\211\211:\203`\262\211A\262\242\262\211@\262\315=\203X\203S\320\262\202XB\262AA\262\202/\266\320\211:\203\226@\262\321\322\320\211\211\211\211\211\211\211\211\211\211\323& \211\211\316I\266\211\324\324HBI\266A\262\202d\266\314\325\"\203\365\326\211\327! !\n!]X\203\342\330\331\327\330\332\314 \325\"\"#X\203\326r\333 !q\210\317\211db\210\211\334\261\210*X\203\341\335\336\"\210\210\266\337H\204\365\211\337\314\325\"I\266\340\341p#\207" [url-http-response-status request-log-level request-message-level request-log-buffer-name buffer-read-only inhibit-read-only plist-member :response :url featurep url-http 1 plist-get :redirect 6 t nil record request-response url-retrieve 2 :error #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] warn format "[%s] %s" "request--url-retrieve-callback: %s" get-buffer-create "\n" message "%s" 4 apply request--callback] 21 (#$ . 38297)]) #@239 Internal synchronous retrieve of URL. SETTINGS include typical TYPE DATA TIMEOUT RESPONSE properties. HEADERS needs to be assigned after SETTINGS is preprocessed. (fn URL &rest SETTINGS &key TYPE DATA TIMEOUT RESPONSE &allow-other-keys) (defalias 'request--url-retrieve-sync #[385 "\304\305\"A@\304\306\"A@\304\307\"A@\304\310\"A@\311\312\313\"\262\314\315\"\262\211\203j\3162L\317\311\320#\211 B\321\322\"\216\323\324\"*\2620\211\316=\203d\211\325\326I\266\211\327\324I\266\311\202e\211\262\202o\323\324\"\211\330I\266\211\203\230r\211q\210eb\210\331 \304\332\"A@\211\333I\266)\312\334 #\210+\210\207" [url-request-extra-headers url-request-method url-request-data with-timeout-timers plist-member :type :data :timeout :response nil apply request--url-retrieve-preprocess-settings plist-get :headers #1=#:timeout run-with-timer #[0 "\300\301\211\"\207" [throw #1#] 3] make-closure #[0 "\301\300!\207" [V0 cancel-timer] 2] url-retrieve-synchronously t 5 timeout 7 9 request--parse-response-at-point :code 1 request--callback] 14 (#$ . 39679)]) #@86 Retrieve cookies corresponding to HOST LOCALPART SECURE. (fn HOST LOCALPART SECURE) (defalias 'request--url-retrieve-get-cookies #[771 "\300\301\302#\"\207" [mapcar #[257 "\211\301H>\204\302\303\304D\"\210\211\305H\301H>\204!\302\303\304D\"\210\306HB\207" [cl-struct-url-cookie-tags 0 signal wrong-type-argument url-cookie 1 2] 6 "\n\n(fn C)"] url-cookie-retrieve] 9 (#$ . 40775)]) #@103 Override what the function `request--curl-cookie-jar' returns. Currently it is used only for testing. (defvar request--curl-cookie-jar nil (#$ . 41177)) #@34 Cookie storage for curl backend. (defalias 'request--curl-cookie-jar #[0 "\206\302\303 \"\207" [request--curl-cookie-jar request-storage-directory expand-file-name "curl-cookie-jar"] 3 (#$ . 41336)]) #@81 Used to avoid invoking curl more than once for version info. By skeeto/elfeed. (defvar request--curl-capabilities-cache (make-hash-table :test 'eq :weakness 'key) (#$ . 41545)) #@148 Return capabilities plist for curl. By skeeto/elfeed. :version -- cURL's version string :compression -- non-nil if --compressed is supported. (defalias 'request--curl-capabilities #[0 "\302 \"\211\203 \207\303\304\305\"r\211q\210\306\307\"\216\310\311\305\311\312%\210eb\210\313\314\311\305#\205,\315\316!eb\210\313\317\311\305#?? \320\321\322F#\266\204*\207" [request-curl request--curl-capabilities-cache gethash generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] call-process nil "--version" re-search-forward "[.0-9]+" match-string 0 "libz\\>" puthash :version :compression] 12 (#$ . 41730)]) (defconst request--curl-write-out-template (byte-code "\301=\203\302\207\303\207" [system-type windows-nt "\\n(:num-redirects %{num_redirects} :url-effective %{url_effective})" "\\n(:num-redirects %{num_redirects} :url-effective \"%{url_effective}\")"] 2)) #@390 Internal command cobbler for curl to URL. TYPE, DATA, HEADERS, FILES, UNIX-SOCKET, AUTH are as described in `request'. COOKIE-JAR is the file location for the netscape cookie jar, usually in the request subdirectory of `user-emacs-directory'. BUG: Simultaneous requests are a known cause of cookie-jar corruption. (fn URL &key TYPE DATA HEADERS FILES UNIX-SOCKET AUTH &allow-other-keys) (defalias 'request--curl-command #[385 "\306\307\"A@\306\310\"A@\306\311\"A@\306\312\"A@\306\313\"A@\306\314\"A@\315\316\317 !!\320\321\322\323\324\257\205\210\325 !\326! >\204M\327\330\331D\"\210\211\332H\262\333\334\335\"B\336B\337\340\341\342\343\344\345\346&@\347\334\350\351\352\"\351\353\"\354!\203\200\211 \202\201\211\262$!)\266\202 \211;\205\246\325!\326! >\204\241\327\330\331D\"\210\211\346H\262\211;\205\271\355\356\344\357#)\266\203?\266\202?\205\303\360\361\fE \351\362 \363\"\205\316\364C\205\327\365 D\f \356\211\211:\203\211@\262\211A\262\242\262\366B\262\367\334\370;\203\371!\372F\202}\373!\203)\203\374\375!\210\202\344\262\376\377!\372F\202}<\203v\351A\201@\"\204H\203E\374\375!\210\202H\344\262\351A\201@\"\206U\376@\351 \201A\"\203q\334\201B\351 \201A\"\"\202r\372F\202}\374\201C\"#B\262A\262\202\336\211\237\266\205 \205\227\347\201D!\205\263\227\201E\232\203\255\201FC\202\263\201GD\356\211\211:\203\342@\262\211A\262\242\262\201HB\262\334\201I#B\262A\262\202\270\211\237\266\204C& \207" [request-curl cl-struct-url-tags auth-source-creation-prompts inhibit-changing-match-data request--curl-write-out-template request-curl-options plist-member :type :data :headers :files :unix-socket :auth convert-standard-filename expand-file-name request--curl-cookie-jar append "--silent" "--location" "--cookie" "--cookie-jar" url-generic-parse-url type-of signal wrong-type-argument url 4 user format "%s user: " ((secret . "Password for %u: ")) auth-source-search :host :require (:user :secret) :create t :max 1 split-string "--%s --user %s:%s" plist-get :user :secret functionp "^http" nil string-match "--include" "--write-out" request--curl-capabilities :compression "--compressed" "--unix-socket" "--form" apply "%s=@%s;filename=%s%s" file-name-nondirectory "" bufferp error "request--curl-command: only one buffer or data entry permitted" "-" buffer-name :file :mime-type ";type=%s" "request--curl-command: %S not string, buffer, or list" "--data-binary @-" "head" "--head" "--request" "--header" "%s: %s"] 32 (#$ . 42672)]) #@96 Out-of-band trigger after TIMEOUT seconds to forestall a hung RESPONSE. (fn TIMEOUT RESPONSE) (defalias 'request--install-timeout #[514 "\247\205\211\211\300\301\302\303$I\262\207" [11 run-at-time nil request-response--timeout-callback] 10 (#$ . 45270)]) #@81 Simple regex filter on anything looking like a secret in COMMAND. (fn COMMAND) (defalias 'request--curl-occlude-secret #[257 "\300\301\"\211\203\302\303\304\211\305%\207\207" [string-match "--user\\s-*\\(\\S-+\\)" replace-match "elided" nil 1] 8 (#$ . 45539)]) #@1102 Internal workhorse querying URL via curl. SETTINGS is a property list with keys (some optional) such as DATA for posting fields, FILES containing one or more lists of the form (NAME . FILENAME) (NAME . BUFFER) (NAME . (FILENAME :buffer BUFFER)) (NAME . (FILENAME :data DATA)) with NAME and FILENAME defined by curl(1)'s overwrought `--form` switch format, TIMEOUT in seconds, RESPONSE a mandatory struct, ENCODING, and SEMAPHORE, an internal semaphore. Redirection handling strategy ----------------------------- curl follows redirection when --location is given. However, all headers are printed when it is used with --include option. Number of redirects is printed out sexp-based message using --write-out option (see `request--curl-write-out-template'). This number is used for removing extra headers and parse location header from the last redirection header. Sexp at the end of buffer and extra headers for redirects are removed from the buffer before it is shown to the parser function. (fn URL &rest SETTINGS &key DATA FILES TIMEOUT RESPONSE ENCODING SEMAPHORE &allow-other-keys) (defalias 'request--curl #[385 "\306\307\"A@\306\310\"A@\306\311\"A@\306\312\"A@\306\313\"A@\306\314\"A@\31515\316\317\320 !\321\"0\210\2026\210\322\323 !\206?\324\325!\326\327!\330\331  #\330\332\333$\334\335\n\"\336\337\"\206c\336\340\"\336\341\"\342  \"\210\343\211\344!\n! !]X\203\265\345\346\344\345\347\350\351\352\353#!\"#X\203\251r\354\f!q\210\321\211@db\210\211\355\261\210*X\203\264\356\357\"\210\210\266 \211\360I\266\361\362\f#\210\363\364\211#\210\365\322\"\210\f\204\337\204\337\211\2030\366\367!\370A\371\372\"\216\373\367\364\"\210\326\374\321\"r\211q\210\371\375\"\216\376\367!\210\n7\206\203rq\210\377ed\")\206c\210\201Bed#\210\201C!\210*\210*\210\201D\201E\"\203N\201F\371\201G\f#\"\202T\201F\"\262*\207" [process-connection-type default-directory request-log-level request-message-level request-log-buffer-name buffer-read-only plist-member :data :files :timeout :response :encoding :semaphore (error) make-directory file-name-directory request--curl-cookie-jar t nil file-remote-p "~/" expand-file-name generate-new-buffer " *request curl*" apply request--curl-command start-process "request curl" mapcar cdr cl-some #[257 "\300!\205\211\207" [bufferp] 3 "\n\n(fn ITEM)"] #[257 "\211<\205\n\300A\301\"\207" [plist-get :buffer] 4 "\n\n(fn ITEM)"] #[257 "\211<\205\n\300A\301\"\207" [plist-get :data] 4 "\n\n(fn ITEM)"] request--install-timeout #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] debug format "[%s] %s" "request--curl: %s" request--curl-occlude-secret mapconcat identity " " get-buffer-create "\n" message "%s" 9 process-put :request-response set-process-coding-system no-conversion set-process-query-on-exit-flag default-value buffer-file-coding-system #[128 "\300\207" [t] 2 "\n\n(fn &rest _)"] make-closure #[0 "\301\302\300\"\207" [V0 set-default buffer-file-coding-system] 3] set-default " *temp*" #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] make-local-variable buffer-substring-no-properties inhibit-read-only select-safe-coding-system-accept-default-p process-send-region process-send-eof apply-partially request--curl-callback set-process-sentinel #[128 "\302\301\"\210\302\300\"\207" [V0 V1 apply] 4 "\n\n(fn &rest ARGS)"]] 30 (#$ . 45814)]) #@185 Read a sexp at the end of buffer and remove it and preceding character. This function moves the point at the end of buffer by side effect. See also `request--curl-write-out-template'. (defalias 'request--curl-read-and-delete-tail-info #[0 "\301db\210\302\303!\210`S\304p!d|\210\262)\207" [forward-sexp-function nil forward-sexp -1 read] 4 (#$ . 49282)]) #@90 Uninterested keys in cookie. See "set-cookie-av" in https://www.ietf.org/rfc/rfc2965.txt (defconst request--cookie-reserved-re (mapconcat #[257 "\300\301Q\207" ["\\(^" "\\'\\)"] 4 "\n\n(fn X)"] '("comment" "commenturl" "discard" "domain" "max-age" "path" "port" "secure" "version" "expires") "\\|") (#$ . 49645)) #@51 Remove "HTTP/* 100 Continue" header at the point. (defalias 'request--consume-100-continue #[0 "\212\305 )\306\307\"A@\211\310=\205b\311\211\312!! !]X\203W\313\314\312\313\315`\212\316\317!\210`){\"#X\203Kr\320\n!q\210\317\211db\210\211\321\261\210*X\203V\322\323\"\210\210\266`\316 \210`|\210\324 \207" [request-log-level request-message-level request-log-buffer-name buffer-read-only inhibit-read-only request--parse-response-at-point plist-member :code 100 #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] debug format "[%s] %s" "request--consume-100-continue: consuming\n%s" request--goto-next-body t get-buffer-create "\n" message "%s" request--consume-100-continue] 15 (#$ . 49965)]) #@65 Remove "HTTP/* 200 Connection established" header at the point. (defalias 'request--consume-200-connection-established #[0 "\301\302\303!)\262\205`\304 \210`|\207" [inhibit-changing-match-data "HTTP/1\\.[0-1] 200 Connection established" t looking-at request--goto-next-body] 3 (#$ . 50730)]) #@130 Pre-process current buffer before showing it to user. Curl switches need to be adjusted if URL is a file://. (fn &optional URL) (defalias 'request--curl-preprocess #[256 "\303\211;\205\304!\305!>\204\306\307\310D\"\210\211\311H\262\211;\2051\312\303\313\314#)\266\203?\266\202\203>\315\316\317F\202@\320 \321\315\"A@\321\317\"A@eb\210\322 \210\323 \210\316V\203\217\313\211S\211\262\316Y\203\215\322 \210\324\325\303\211\211\211\211\211\211\211p\303\211\326& \327!\210\330!\210\211B\262\210\202^)\210eb\210\315\317\331\237\257\332 \244\207" [cl-struct-url-tags inhibit-changing-match-data case-fold-search nil url-generic-parse-url type-of signal wrong-type-argument url 1 "^http" t string-match :num-redirects 0 :url-effective request--curl-read-and-delete-tail-info plist-member request--consume-100-continue request--consume-200-connection-established record request-response curl request--clean-header request--cut-header :history request--parse-response-at-point] 20 (#$ . 51034)]) #@113 Convert relative paths in REDIRECTS to absolute URLs. START-URL is the URL requested. (fn START-URL REDIRECTS) (defalias 'request--curl-absolutify-redirects #[514 "\301\301\211\302\211\203\202\262:\2037@\262\303\"\204(\304\"\262B\262A\262\301\262\202\237\207" [url-nonrelative-link nil t string-match url-expand-file-name] 10 (#$ . 52067)]) #@109 Convert relative paths in HISTORY to absolute URLs. START-URL is the URL requested. (fn START-URL HISTORY) (defalias 'request--curl-absolutify-location-history #[514 "\211\203\f\211@\211\300I\266\301\302\303\"\"\304A\304:\203;@\262:\203;@\262\211\211\300I\266A\262A\262\202\304\207" [6 request--curl-absolutify-redirects mapcar #[257 "\300\301\"\206\n\211\302H\207" [request-response-header "location" 6] 4 "\n\n(fn RESPONSE)"] nil] 10 (#$ . 52445)]) #@145 Ensure `request--callback' gets called after curl to URL finishes. See info entries on sentinels regarding PROC and EVENT. (fn URL PROC EVENT) (defalias 'request--curl-callback #[771 "\305!\306\307\"\211\310H\311\211\312!! !]X\203J\313\314\312\313\315\f\"#X\203>r\316\n!q\210\317\211db\210\211\320\261\210*X\203I\321\322\"\210\210\266\323\211\324!! !]X\203\231\313\314\324\313\325\326\f!\205rr q\210\327 )\"#X\203\215r\316\n!q\210\317\211db\210\211\320\261\210*X\203\230\321\322\"\210\210\266\330!\331>\203\273\332!\333U\204\273\211\334\335BI\266\336\337#\207\340\341\"\2058\3421\323rq\210\343!)0\202\330\344D\262\345\346\"A@\345\347\"A@\345\344\"A@\345\350\"A@\351\352\353\"\"\210\211\354I\266\211\355I\266\211\356I\266\211\334\206,\247\205,\357Y\205,\335\360EI\266\336\337 #\266\205\207" [request-log-level request-message-level request-log-buffer-name buffer-read-only inhibit-read-only process-buffer process-get :request-response 8 #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] debug format "[%s] %s" "request--curl-callback: event %s" get-buffer-create t "\n" message "%s" #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] trace "request--curl-callback: raw-bytes=\n%s" buffer-live-p buffer-string process-status (exit signal) process-exit-status 0 4 error apply request--callback cl-search "finished" (debug error) request--curl-preprocess :error plist-member :code :history :url-effective request--curl-absolutify-location-history plist-get :url 1 6 2 400 http] 18 (#$ . 52928)]) #@66 Backport of M. Engdegard's fix of `auto-revert-notify-rm-watch'. (defalias 'request-auto-revert-notify-rm-watch #[0 "\304\301!\203 \202\304\302!\205\n\203H\211\203H\305p\306\"\"\211\203/\307#\266\2025\310\"\266\3111A\312!0\210\202B\210\313\314\315\316#\210\266\317\211\211\207" [auto-revert-notify-watch-descriptor auto-revert--buffers-by-watch-descriptor auto-revert-notify-watch-descriptor-hash-list auto-revert-notify-modified-p boundp delq gethash puthash remhash (error) file-notify-rm-watch remove-hook kill-buffer-hook auto-revert-notify-rm-watch t nil] 8 (#$ . 54620)]) #@131 Internal synchronous curl call to URL with SETTINGS bespeaking RESPONSE. (fn URL &rest SETTINGS &key RESPONSE &allow-other-keys) (defalias 'request--curl-sync #[385 "\306\307\"A@\310C\311\312\313\314\315\"%\316\317H!\320\321\322 \210\203:\323 \211\2039\211@r\211q\210\324 \210)A\266\202\202$\210\3251\266\310\326\211Y\204^\242\204^\327\310\"\210\330!\204A\211T\262\202A\211\321Y\205\257\331\332\333\334\"\335\"\210\336\211\337!\n! !]X\205\253\332\340\337\332\334!#X\203\237r\341\f!q\210\342\211(db\210\211\343\261\210*X\205\251\344\345\"\262\266\203\262\262)0\266\207\210\342)\346\347!\266\207" [auto-revert-use-notify inhibit-quit request-log-level request-message-level request-log-buffer-name buffer-read-only plist-member :response nil apply request--curl :semaphore make-closure #[128 "\300\301\240\207" [V0 t] 3 "\n\n(fn &rest _)"] get-buffer-process 9 0.05 100 auto-revert-set-timer buffer-list request-auto-revert-notify-rm-watch (quit) 0 accept-process-output process-live-p princ format "%s\n" "request--curl-sync: semaphore never called" external-debugging-output #[257 "\211\250\203\207\211\236A\206\301\207" [request--log-level-def 0] 3 "\n\n(fn LEVEL)"] error "[%s] %s" get-buffer-create t "\n" message "%s" eval (ignore nil) inhibit-read-only quit-flag] 19 (#$ . 55232)]) #@83 Return entry for HOST LOCALPART SECURE in cookie jar. (fn HOST LOCALPART SECURE) (defalias 'request--curl-get-cookies #[771 "\300\301 $\207" [request--netscape-get-cookies request--curl-cookie-jar] 8 (#$ . 56577)]) #@39 Parse Netscape/Mozilla cookie format. (defalias 'request--netscape-cookie-parse #[0 "eb\210\301\302\303S\211\262\304Y\203\211\305P\262\202\262\306Q\307m\204p\310\311\312!)\262\2039\313\311\312!)\262\203j\314\311\312!)\262\204j\312!\203j\315\307\316X\203a\317!B\262T\262\202M\211\237\266\202\211B\266\202\315y\210\202\211\237\262\211\307\211\211\211\211\211\211\211\211\211\n:\203\354\n@\262\211A\262\242\262\n\211A\262\242\262 \211A\262\242\262\211A\262\242\262\211A\262\242\262\211A\262\242\262\211A\262\242\262@\262\320\232\320\232 ??\321\n!  \257B\262\nA\262 \202\211\237\207" [inhibit-changing-match-data "^\\(#HttpOnly_\\)?" 6 "" 0 "\\([^ \n]+\\) " "\\(.*\\)" nil "^#" t looking-at "^#HttpOnly_" "^$" 1 8 match-string "TRUE" string-to-number] 21 (#$ . 56802)]) #@98 Filter COOKIES for entries containing HOST LOCALPART SECURE. (fn COOKIES HOST LOCALPART SECURE) (defalias 'request--netscape-filter-cookies #[1028 "\300\211\211\211\211\211\211\211\211\211\n:\203}\n@\262\211A\262\242\262\n\211A\262\242\262\211A\262\242\262 \211A\262\242\262\211A\262\242\262\211A\262\242\262\211A\262\242\262@\262 \232\203u \232\203u \204l\204uBB\262\nA\262 \202 \211\237\207" [nil] 17 (#$ . 57652)]) #@104 Get cookies from FILENAME corresponding to HOST LOCALPART SECURE. (fn FILENAME HOST LOCALPART SECURE) (defalias 'request--netscape-get-cookies #[1028 "\300!\205$\301\302\303\"r\211q\210\304\305\"\216\306 \210\307!\210\310\311 $*\262\207" [file-readable-p generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] erase-buffer insert-file-contents request--netscape-filter-cookies request--netscape-cookie-parse] 10 (#$ . 58125)]) (provide 'request)