diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-12-20 15:47:56 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-12-20 15:48:49 -0200 |
commit | 0c380f42cf56e64d3b4446b6168fa8028760d8c5 (patch) | |
tree | 4c3818859e8fbe111b5322abe62961fb144a64fa /sx-request.el | |
parent | 5ee595c3740c2b24274c9405e4bed4a5ae81953f (diff) |
Prefer zlib-decompress-region when available.
Fix #157
Diffstat (limited to 'sx-request.el')
-rw-r--r-- | sx-request.el | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sx-request.el b/sx-request.el index 389a471..9f2ecdb 100644 --- a/sx-request.el +++ b/sx-request.el @@ -70,7 +70,11 @@ (defcustom sx-request-unzip-program "gunzip" "Program used to unzip the response if it is compressed. -This program must accept compressed data on standard input." +This program must accept compressed data on standard input. + +This is only used (and necessary) if the function +`zlib-decompress-region' is not defined, which is the case for +Emacs versions < 24.4." :group 'sx :type 'string) @@ -133,10 +137,11 @@ the main content of the response is returned." (buffer-string)))) (response-zipped-p (sx-encoding-gzipped-p data)) (data (if (not response-zipped-p) data - (shell-command-on-region - (point-min) (point-max) - sx-request-unzip-program - nil t) + (if (fboundp 'zlib-decompress-region) + (zlib-decompress-region (point-min) (point-max)) + (shell-command-on-region + (point-min) (point-max) + sx-request-unzip-program nil t)) (buffer-string))) ;; @TODO should use `condition-case' here -- set ;; RESPONSE to 'corrupt or something |