summaryrefslogtreecommitdiff
path: root/lisp/url
diff options
context:
space:
mode:
authorJuanma Barranquero <lekktu@gmail.com>2014-03-26 16:21:17 +0100
committerJuanma Barranquero <lekktu@gmail.com>2014-03-26 16:21:17 +0100
commit196716cf35f81bea108c3b75362e92c86ed1c016 (patch)
treecf8bb35bce13cc25dce33c659f6d89bfd87f146b /lisp/url
parent589d1988d8051a3744892e925231b9e5027fe99a (diff)
downloademacs-196716cf35f81bea108c3b75362e92c86ed1c016.tar.gz
* lisp/emacs-lisp/package.el: Fix bug#16733 (again).
(url-http-parse-response, url-http-end-of-headers, url-recreate-url) (url-http-target-url): Remove unused declarations. (package-handle-response): Remove. (package--with-work-buffer): Use url-insert-file-contents and simplify. (package--download-one-archive): Use current-buffer instead of dynamic binding of `buffer'. (describe-package-1): Do not decode readme-string. * lisp/url/url-handlers.el (url-http-parse-response): Add autoload. (url-insert-file-contents): Signal file-error in case of HTTP error.
Diffstat (limited to 'lisp/url')
-rw-r--r--lisp/url/ChangeLog5
-rw-r--r--lisp/url/url-handlers.el12
2 files changed, 15 insertions, 2 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 0cdcc139905..cb37b4511bd 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-26 Juanma Barranquero <lekktu@gmail.com>
+
+ * url-handlers.el (url-http-parse-response): Add autoload.
+ (url-insert-file-contents): Signal file-error in case of HTTP error.
+
2014-02-05 Glenn Morris <rgm@gnu.org>
* url-cookie.el (url-cookie-list): Doc fix.
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el
index e52aad83e47..ecf56e786b5 100644
--- a/lisp/url/url-handlers.el
+++ b/lisp/url/url-handlers.el
@@ -33,6 +33,7 @@
(autoload 'url-expand-file-name "url-expand" "Convert url to a fully specified url, and canonicalize it.")
(autoload 'mm-dissect-buffer "mm-decode" "Dissect the current buffer and return a list of MIME handles.")
(autoload 'url-scheme-get-property "url-methods" "Get property of a URL SCHEME.")
+(autoload 'url-http-parse-response "url-http" "Parse just the response code.")
;; Always used after mm-dissect-buffer and defined in the same file.
(declare-function mm-save-part-to-file "mm-decode" (handle file))
@@ -293,8 +294,15 @@ They count bytes from the beginning of the body."
;;;###autoload
(defun url-insert-file-contents (url &optional visit beg end replace)
(let ((buffer (url-retrieve-synchronously url)))
- (if (not buffer)
- (error "Opening input file: No such file or directory, %s" url))
+ (unless buffer (signal 'file-error (list url "No Data")))
+ (with-current-buffer buffer
+ (let ((response (url-http-parse-response)))
+ (if (and (>= response 200) (< response 300))
+ (goto-char (point-min))
+ (let ((desc (buffer-substring-no-properties (1+ (point))
+ (line-end-position))))
+ (kill-buffer buffer)
+ (signal 'file-error (list url desc))))))
(if visit (setq buffer-file-name url))
(save-excursion
(let* ((start (point))