- To: emacs-devel@xxxxxxxxxxx
- Subject: Re: url-http.el breaks Emacs/W3
- From: Magnus Henoch <mange@xxxxxxxxxxx>
- Date: Tue, 19 Sep 2006 10:24:20 +0300
- Cancel-Lock: sha1:kVoSyvCQK2Jp9977qJYvNFtoGAY=
- Jabber-Id: legoscia@xxxxxxxxxxx
- List-Archive: <http://lists.gnu.org/pipermail/emacs-devel>
- List-Help: <mailto:emacs-devel-request@xxxxxxxxxxx?subject=help>
- List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
- List-Post: <mailto:emacs-devel@xxxxxxxxxxx>
- List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,<mailto:emacs-devel-request@xxxxxxxxxxx?subject=subscribe>
- List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,<mailto:emacs-devel-request@xxxxxxxxxxx?subject=unsubscribe>
- Mail-Copies-To: never
- Mail-Followup-To: emacs-devel@xxxxxxxxxxx
- User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (berkeley-unix)
"T. V. Raman" <raman@xxxxxxxxxxx> writes:
> I finally got a little more detail on where this breakage is
> occuring.
>
> Symptoms:
>
> If you use Emacs/w3 and use the URL package out of Emacs CVS you
> hit an error on sites that do a redirect e.g. http://sf.net
>
> The error is very difficult to track down because it's being
> thrown from the w3 site in w3-fetch-callback.
>
> But I have verified that the problem appears to be isolated in
> url-http.el, i.e. if you use package url out of Emacs 22 CVS,
> and load url-http.el by hand from William Perry's original CVS
> snapshot on savannah, then everything works correctly.
As far as I can see, the problem is that the interface of
`url-retrieve' changed, but W3 wasn't adapted. I have been seeing the
same problem, and have been using the patch below with good results.
The patch is less complicated than it looks; most of it is changed
indentation. I have sent this to w3-devel as well.
Magnus
*** w3.el 03 Mar 2006 05:13:41 +0200 1.32
--- w3.el 01 Sep 2006 03:30:17 +0300
***************
*** 293,375 ****
(w3-setup-reload-timer uri (url-view-url t)
(string-to-int (or reload "5"))))))
! (defun w3-fetch-callback (url)
! (w3-nasty-disgusting-http-equiv-handling (current-buffer) url)
! ;; Process any cookie and refresh headers.
! (let (headers)
! (ignore-errors
! (save-restriction
! (mail-narrow-to-head)
! (goto-char (point-min))
! (unless (save-excursion
! (search-forward ":" (line-end-position) t))
! (forward-line))
! (setq headers (mail-header-extract))
! (let (refreshed)
! (dolist (header headers)
! ;; Act on multiple cookies if necessary, but only on a
! ;; single refresh request in case there's more than one.
! (case (car header)
! (refresh (unless refreshed
! (w3-handle-refresh-header (cdr header))
! (setq refreshed t))))))))
! (let ((handle (mm-dissect-buffer t))
! (w3-explicit-coding-system
! (or w3-explicit-coding-system
! (w3-recall-explicit-coding-system url)))
! (buff nil))
! (message "Downloading of `%s' complete." url)
! (url-mark-buffer-as-dead (current-buffer))
! (unless headers
! (setq headers (list (cons 'content-type
! (mm-handle-media-type handle)))))
! ;; Fixme: can handle be null?
! (cond
! ((equal (mm-handle-media-type handle) "text/html")
! ;; Special case text/html if it comes through w3-fetch
! (set-buffer (generate-new-buffer " *w3-html*"))
! (mm-disable-multibyte)
! (mm-insert-part handle)
! (w3-decode-charset handle)
! (setq url-current-object (url-generic-parse-url url))
! (w3-prepare-buffer)
! (setq url-current-mime-headers headers)
! (w3-notify-when-ready (current-buffer))
! (mm-destroy-parts handle))
! ;; ((equal (mm-handle-media-type handle) "text/xml")
! ;; ;; Special case text/xml if it comes through w3-fetch
! ;; (set-buffer (generate-new-buffer " *w3-xml*"))
! ;; (mm-disable-multibyte)
! ;; (mm-insert-part handle)
! ;; (w3-decode-charset handle)
! ;; !!! Need some function to view XML nicely... maybe the
! ;; !!! customize tree control?
! ;; (setq url-current-object (url-generic-parse-url url)
! ;; url-current-mime-headers headers)
! ;; (mm-destroy-parts handle)
! ;; (w3-notify-when-ready (current-buffer)))
! ((equal (car-safe (mm-handle-type handle))
! "application/x-elisp-parsed-html")
! ;; Also need to special-case pre-parsed representations of HTML.
! ;; Fixme: will this need decoding?
! (w3-prepare-tree (read (set-marker (make-marker) 1
! (mm-handle-buffer handle)))))
! ((mm-inlinable-p handle)
! ;; We can view it inline!
! (set-buffer (generate-new-buffer url))
! (require 'mm-view) ; make sure methods are defined
! (mm-display-part handle)
! (set-buffer-modified-p nil)
! (w3-mode)
! (if (equal "image" (mm-handle-media-supertype handle))
! (setq cursor-type nil))
! (setq url-current-mime-headers headers)
! (w3-notify-when-ready (current-buffer)))
! (t
! ;; Must be an external viewer
! (mm-display-part handle)
! ;;(mm-destroy-parts handle)
! )))))
;;;###autoload
(defun w3-fetch (&optional url target)
--- 293,382 ----
(w3-setup-reload-timer uri (url-view-url t)
(string-to-int (or reload "5"))))))
! (defun w3-fetch-callback (&rest args)
! (let ((url (cond
! ;; see callback argument conventions in docstring of
! ;; `url-retrieve'
! ((eq (car args) :redirect)
! (caddr args))
! (t
! (car args)))))
! (w3-nasty-disgusting-http-equiv-handling (current-buffer) url)
! ;; Process any cookie and refresh headers.
! (let (headers)
! (ignore-errors
! (save-restriction
! (mail-narrow-to-head)
! (goto-char (point-min))
! (unless (save-excursion
! (search-forward ":" (line-end-position) t))
! (forward-line))
! (setq headers (mail-header-extract))
! (let (refreshed)
! (dolist (header headers)
! ;; Act on multiple cookies if necessary, but only on a
! ;; single refresh request in case there's more than one.
! (case (car header)
! (refresh (unless refreshed
! (w3-handle-refresh-header (cdr header))
! (setq refreshed t))))))))
! (let ((handle (mm-dissect-buffer t))
! (w3-explicit-coding-system
! (or w3-explicit-coding-system
! (w3-recall-explicit-coding-system url)))
! (buff nil))
! (message "Downloading of `%s' complete." url)
! (url-mark-buffer-as-dead (current-buffer))
! (unless headers
! (setq headers (list (cons 'content-type
! (mm-handle-media-type handle)))))
! ;; Fixme: can handle be null?
! (cond
! ((equal (mm-handle-media-type handle) "text/html")
! ;; Special case text/html if it comes through w3-fetch
! (set-buffer (generate-new-buffer " *w3-html*"))
! (mm-disable-multibyte)
! (mm-insert-part handle)
! (w3-decode-charset handle)
! (setq url-current-object (url-generic-parse-url url))
! (w3-prepare-buffer)
! (setq url-current-mime-headers headers)
! (w3-notify-when-ready (current-buffer))
! (mm-destroy-parts handle))
! ;; ((equal (mm-handle-media-type handle) "text/xml")
! ;; ;; Special case text/xml if it comes through w3-fetch
! ;; (set-buffer (generate-new-buffer " *w3-xml*"))
! ;; (mm-disable-multibyte)
! ;; (mm-insert-part handle)
! ;; (w3-decode-charset handle)
! ;; !!! Need some function to view XML nicely... maybe the
! ;; !!! customize tree control?
! ;; (setq url-current-object (url-generic-parse-url url)
! ;; url-current-mime-headers headers)
! ;; (mm-destroy-parts handle)
! ;; (w3-notify-when-ready (current-buffer)))
! ((equal (car-safe (mm-handle-type handle))
! "application/x-elisp-parsed-html")
! ;; Also need to special-case pre-parsed representations of HTML.
! ;; Fixme: will this need decoding?
! (w3-prepare-tree (read (set-marker (make-marker) 1
! (mm-handle-buffer handle)))))
! ((mm-inlinable-p handle)
! ;; We can view it inline!
! (set-buffer (generate-new-buffer url))
! (require 'mm-view) ; make sure methods are defined
! (mm-display-part handle)
! (set-buffer-modified-p nil)
! (w3-mode)
! (if (equal "image" (mm-handle-media-supertype handle))
! (setq cursor-type nil))
! (setq url-current-mime-headers headers)
! (w3-notify-when-ready (current-buffer)))
! (t
! ;; Must be an external viewer
! (mm-display-part handle)
! ;;(mm-destroy-parts handle)
! ))))))
;;;###autoload
(defun w3-fetch (&optional url target)
_______________________________________________
Emacs-devel mailing list
Emacs-devel@xxxxxxxxxxx
http://lists.gnu.org/mailman/listinfo/emacs-devel