all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* url-http.el breaks Emacs/W3
@ 2006-09-14  3:59 T. V. Raman
  2006-09-19  7:24 ` Magnus Henoch
  0 siblings, 1 reply; 2+ messages in thread
From: T. V. Raman @ 2006-09-14  3:59 UTC (permalink / raw)


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.

There are  a number of bug  fixes in url-http.el 
in the Emacs CVS repos -- so simply going back to Bill's version
is not a good idea either.

Could someone here help me chase this down further?

To reproduce the problem:

Pull w3 from savannah cvs, ./configure
--with-emacs=<path-to-emacs-22> make 
then do 
M-x w3-fetch http://sf.net 
the above URL produces a 301 redirect to the actual SF site which
triggers the error
 Thanks, 
 --Raman

-- 
Best Regards,
--raman

      
Email:  raman@users.sf.net
WWW:    http://emacspeak.sf.net/raman/
AIM:    emacspeak       GTalk: tv.raman.tv@gmail.com
PGP:    http://emacspeak.sf.net/raman/raman-almaden.asc
Google: tv+raman 
IRC:    irc://irc.freenode.net/#emacs

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: url-http.el breaks Emacs/W3
  2006-09-14  3:59 url-http.el breaks Emacs/W3 T. V. Raman
@ 2006-09-19  7:24 ` Magnus Henoch
  0 siblings, 0 replies; 2+ messages in thread
From: Magnus Henoch @ 2006-09-19  7:24 UTC (permalink / raw)
  Cc: w3-dev

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

"T. V. Raman" <raman@users.sf.net> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: w3.el.patch --]
[-- Type: text/x-patch, Size: 6716 bytes --]

*** 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)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-09-19  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-14  3:59 url-http.el breaks Emacs/W3 T. V. Raman
2006-09-19  7:24 ` Magnus Henoch

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.