diff options
| author | Stefan Monnier | 2006-02-20 21:54:23 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-02-20 21:54:23 +0000 |
| commit | 9b4cf2318ae64f155a3101a332882dfa7197bc45 (patch) | |
| tree | e3f7a46aee92ca143be1496092af4c045270fb99 | |
| parent | 55d1d8b7316f426923188487858cce1736c4e92b (diff) | |
| download | emacs-9b4cf2318ae64f155a3101a332882dfa7197bc45.tar.gz emacs-9b4cf2318ae64f155a3101a332882dfa7197bc45.zip | |
(url-redirect-buffer): New var.
(url-retrieve-synchronously): Use it to follow redirections.
| -rw-r--r-- | lisp/url/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/url/url.el | 35 |
2 files changed, 34 insertions, 13 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 04cd080db8f..cb002731eec 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2006-02-20 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * url.el (url-redirect-buffer): New var. | ||
| 4 | (url-retrieve-synchronously): Use it to follow redirections. | ||
| 5 | |||
| 6 | * url-http.el: Require `url' rather than try to autoload parts of it. | ||
| 7 | (url-http-find-free-connection): `url-open-stream' needs a real buffer. | ||
| 8 | (url-http-parse-headers): Set `url-redirect-buffer' when following | ||
| 9 | a redirection reply. | ||
| 10 | |||
| 1 | 2006-01-18 Stefan Monnier <monnier@iro.umontreal.ca> | 11 | 2006-01-18 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 12 | ||
| 3 | * url-news.el: Move defvars out of eval-when-compile. | 13 | * url-news.el: Move defvars out of eval-when-compile. |
| @@ -18,7 +28,7 @@ | |||
| 18 | (url-history-save-history): Create parent dir if necessary. | 28 | (url-history-save-history): Create parent dir if necessary. |
| 19 | (url-history-save-history): Don't write the initialization of | 29 | (url-history-save-history): Don't write the initialization of |
| 20 | url-history-hash-table into the history file. | 30 | url-history-hash-table into the history file. |
| 21 | (url-have-visited-url): Simplify since url-history-hash-table is non-nil. | 31 | (url-have-visited-url): Simplify since url-history-hash-table isn't nil. |
| 22 | (url-completion-function): Simplify. | 32 | (url-completion-function): Simplify. |
| 23 | 33 | ||
| 24 | * url-cookie.el (url-cookie-parse-file): Don't complain of missing file. | 34 | * url-cookie.el (url-cookie-parse-file): Don't complain of missing file. |
diff --git a/lisp/url/url.el b/lisp/url/url.el index 10c449cb30b..07ac55dcd3d 100644 --- a/lisp/url/url.el +++ b/lisp/url/url.el | |||
| @@ -114,6 +114,13 @@ Emacs." | |||
| 114 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 114 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 115 | ;;; Retrieval functions | 115 | ;;; Retrieval functions |
| 116 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 116 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 117 | |||
| 118 | (defvar url-redirect-buffer nil | ||
| 119 | "New buffer into which the retrieval will take place. | ||
| 120 | Sometimes while retrieving a URL, the URL library needs to use another buffer | ||
| 121 | than the one returned initially by `url-retrieve'. In this case, it sets this | ||
| 122 | variable in the original buffer as a forwarding pointer.") | ||
| 123 | |||
| 117 | ;;;###autoload | 124 | ;;;###autoload |
| 118 | (defun url-retrieve (url callback &optional cbargs) | 125 | (defun url-retrieve (url callback &optional cbargs) |
| 119 | "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished. | 126 | "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished. |
| @@ -189,18 +196,22 @@ no further processing). URL is either a string or a parsed URL." | |||
| 189 | (url-debug 'retrieval | 196 | (url-debug 'retrieval |
| 190 | "Spinning in url-retrieve-synchronously: %S (%S)" | 197 | "Spinning in url-retrieve-synchronously: %S (%S)" |
| 191 | retrieval-done asynch-buffer) | 198 | retrieval-done asynch-buffer) |
| 192 | (if (and proc (memq (process-status proc) | 199 | (if (buffer-local-value 'url-redirect-buffer asynch-buffer) |
| 193 | '(closed exit signal failed)) | 200 | (setq proc (get-buffer-process |
| 194 | ;; Make sure another process hasn't been started, as can | 201 | (setq asynch-buffer |
| 195 | ;; happen with http redirections. | 202 | (buffer-local-value 'url-redirect-buffer |
| 196 | (eq proc (or (get-buffer-process asynch-buffer) proc))) | 203 | asynch-buffer)))) |
| 197 | ;; FIXME: It's not clear whether url-retrieve's callback is | 204 | (if (and proc (memq (process-status proc) |
| 198 | ;; guaranteed to be called or not. It seems that url-http | 205 | '(closed exit signal failed)) |
| 199 | ;; decides sometimes consciously not to call it, so it's not | 206 | ;; Make sure another process hasn't been started. |
| 200 | ;; clear that it's a bug, but even then we need to decide how | 207 | (eq proc (or (get-buffer-process asynch-buffer) proc))) |
| 201 | ;; url-http can then warn us that the download has completed. | 208 | ;; FIXME: It's not clear whether url-retrieve's callback is |
| 202 | ;; In the mean time, we use this here workaround. | 209 | ;; guaranteed to be called or not. It seems that url-http |
| 203 | (setq retrieval-done t) | 210 | ;; decides sometimes consciously not to call it, so it's not |
| 211 | ;; clear that it's a bug, but even then we need to decide how | ||
| 212 | ;; url-http can then warn us that the download has completed. | ||
| 213 | ;; In the mean time, we use this here workaround. | ||
| 214 | (setq retrieval-done t)) | ||
| 204 | ;; We used to use `sit-for' here, but in some cases it wouldn't | 215 | ;; We used to use `sit-for' here, but in some cases it wouldn't |
| 205 | ;; work because apparently pending keyboard input would always | 216 | ;; work because apparently pending keyboard input would always |
| 206 | ;; interrupt it before it got a chance to handle process input. | 217 | ;; interrupt it before it got a chance to handle process input. |