X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/697ebdb06b70c96e79b844216c305c3ec2eb7f07..10472dd0d62d986e048c01a3d37627b843a321d2:/lisp/url/url-http.el diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 71de213b64..28071e7165 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -1,7 +1,6 @@ ;;; url-http.el --- HTTP retrieval routines -;; Copyright (C) 1999, 2001, 2004, 2005, 2006, 2007, 2008, 2009, -;; 2010 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2001, 2004-2011 Free Software Foundation, Inc. ;; Author: Bill Perry ;; Keywords: comm, data, processes @@ -874,13 +873,14 @@ should be shown to the user." (url-http-debug "url-http-end-of-document-sentinel in buffer (%s)" (process-buffer proc)) (url-http-idle-sentinel proc why) - (with-current-buffer (process-buffer proc) - (goto-char (point-min)) - (if (not (looking-at "HTTP/")) - ;; HTTP/0.9 just gets passed back no matter what - (url-http-activate-callback) - (if (url-http-parse-headers) - (url-http-activate-callback))))) + (when (buffer-name (process-buffer proc)) + (with-current-buffer (process-buffer proc) + (goto-char (point-min)) + (if (not (looking-at "HTTP/")) + ;; HTTP/0.9 just gets passed back no matter what + (url-http-activate-callback) + (if (url-http-parse-headers) + (url-http-activate-callback)))))) (defun url-http-simple-after-change-function (st nd length) ;; Function used when we do NOT know how long the document is going to be @@ -1034,10 +1034,11 @@ the end of the document." url-http-response-status)) (url-http-debug "url-http-wait-for-headers-change-function (%s)" (buffer-name)) - (when (not (bobp)) - (let ((end-of-headers nil) - (old-http nil) - (content-length nil)) + (let ((end-of-headers nil) + (old-http nil) + (process-buffer (current-buffer)) + (content-length nil)) + (when (not (bobp)) (goto-char (point-min)) (if (and (looking-at ".*\n") ; have one line at least (not (looking-at "^HTTP/[1-9]\\.[0-9]"))) @@ -1054,8 +1055,7 @@ the end of the document." end-of-headers t) (url-http-clean-headers))) - (if (or (not end-of-headers) - (not url-http-response-status)) + (if (not end-of-headers) ;; Haven't seen the end of the headers yet, need to wait ;; for more data to arrive. nil @@ -1077,6 +1077,10 @@ the end of the document." (downcase url-http-transfer-encoding))) (cond + ((null url-http-response-status) + ;; We got back a headerless malformed response from the + ;; server. + (url-http-activate-callback)) ((or (= url-http-response-status 204) (= url-http-response-status 205)) (url-http-debug "%d response must have headers only (%s)." @@ -1152,8 +1156,9 @@ the end of the document." 'url-http-simple-after-change-function))))) ;; We are still at the beginning of the buffer... must just be ;; waiting for a response. - (url-http-debug "Spinning waiting for headers...")) - (goto-char (point-max))) + (url-http-debug "Spinning waiting for headers...") + (when (eq process-buffer (current-buffer)) + (goto-char (point-max))))) ;;;###autoload (defun url-http (url callback cbargs) @@ -1453,5 +1458,4 @@ p3p (provide 'url-http) -;; arch-tag: ba7c59ae-c0f4-4a31-9617-d85f221732ee ;;; url-http.el ends here