[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17549: 24.4.50; regression: url-insert-file-contents
From: |
Leo Liu |
Subject: |
bug#17549: 24.4.50; regression: url-insert-file-contents |
Date: |
Wed, 25 Jun 2014 08:58:49 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (CentOS 6.5) |
On 2014-06-24 16:01 +0200, Juanma Barranquero wrote:
> Sorry. I keep trying to find time to fix this and a few other bugs, but I'm
> very busy right now.
No worries ;)
> AFAIR, originally I wanted a small change, just throw an error in a
> specific case, and Stefan pushed for a bigger (though, I suppose, cleaner)
> fix; there was some back-and-forth and we finally settled on what's
> installed. So perhaps you can go back, reread the bug thread and find
> something in the proposed solutions that fixes the original problem and
> does not cause the one you're reporting.
OK, I read that thread quickly and now understood the decision. I
propose the following solution for now. The patch introduces a compiler
warning on url-http-codes. How best to suppress it?
=== modified file 'lisp/url/url-handlers.el'
--- lisp/url/url-handlers.el 2014-05-12 06:59:30 +0000
+++ lisp/url/url-handlers.el 2014-06-25 00:41:33 +0000
@@ -33,7 +33,6 @@
(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))
@@ -313,12 +312,12 @@
(let ((buffer (url-retrieve-synchronously 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))))
+ (when (bound-and-true-p url-http-response-status)
+ (unless (and (>= url-http-response-status 200)
+ (< url-http-response-status 300))
+ (let ((desc (nth 2 (assq url-http-response-status url-http-codes))))
(kill-buffer buffer)
+ ;; Signal file-error per http://debbugs.gnu.org/16733.
(signal 'file-error (list url desc))))))
(if visit (setq buffer-file-name url))
(save-excursion
@@ -333,6 +332,7 @@
;; usual heuristic/rules that we apply to files.
(decode-coding-inserted-region start (point) url visit beg end
replace))
(list url (car size-and-charset))))))
+
(put 'insert-file-contents 'url-file-handlers 'url-insert-file-contents)
(defun url-file-name-completion (url directory &optional predicate)
=== modified file 'lisp/url/url-http.el'
--- lisp/url/url-http.el 2014-03-29 00:55:44 +0000
+++ lisp/url/url-http.el 2014-06-25 00:23:24 +0000
@@ -48,7 +48,6 @@
(defvar url-http-response-version)
(defvar url-http-target-url)
(defvar url-http-transfer-encoding)
-(defvar url-http-end-of-headers)
(defvar url-show-status)
(require 'url-gw)