From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jerry Asher Newsgroups: gmane.emacs.bugs Subject: bug#10478: Possible fix?? Date: Wed, 11 Jan 2012 00:54:15 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=14dae934061b6b464204b63bf1f8 X-Trace: dough.gmane.org 1326269336 11128 80.91.229.12 (11 Jan 2012 08:08:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 11 Jan 2012 08:08:56 +0000 (UTC) To: 10478@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 11 09:08:51 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RktEp-0001xz-2Y for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Jan 2012 09:08:51 +0100 Original-Received: from localhost ([::1]:45786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RktEl-0002j2-GB for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Jan 2012 03:08:47 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:47897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rkt27-0000pB-3K for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2012 02:55:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rkt23-0004fx-G5 for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2012 02:55:43 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rkt23-0004ft-9R for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2012 02:55:39 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Rkt2Q-0005D4-3o for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2012 02:56:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Jerry Asher Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Jan 2012 07:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10478 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10478-submit@debbugs.gnu.org id=B10478.132626850919955 (code B ref 10478); Wed, 11 Jan 2012 07:56:02 +0000 Original-Received: (at 10478) by debbugs.gnu.org; 11 Jan 2012 07:55:09 +0000 Original-Received: from localhost ([127.0.0.1]:53170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rkt1V-0005Bj-Ef for submit@debbugs.gnu.org; Wed, 11 Jan 2012 02:55:09 -0500 Original-Received: from mail-iy0-f172.google.com ([209.85.210.172]:56121) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rkt1R-0005BI-AF for 10478@debbugs.gnu.org; Wed, 11 Jan 2012 02:55:04 -0500 Original-Received: by iaae16 with SMTP id e16so314149iaa.3 for <10478@debbugs.gnu.org>; Tue, 10 Jan 2012 23:54:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=5hSJDT1pCtn7zDdpnCpJH5XZf3lODL0G9ZXI65aScAU=; b=u1YYRPA3PSB6RiW0VMSLPH27uawZHWO5h65GHaLiOXZ5gyLeSXuBpsUobHOR6Bf7I9 f+JBAyXNGh/UDWykuI1wpoXpXZ5TxLTE1XS4cR5CzewfNKaaOpAVdwLF68EtHlstofIU JS2xjrYL2/XG7o3yjRBlMsCQVPaFCg8gJarAI= Original-Received: by 10.50.45.195 with SMTP id p3mr5459567igm.2.1326268476507; Tue, 10 Jan 2012 23:54:36 -0800 (PST) Original-Received: by 10.42.218.74 with HTTP; Tue, 10 Jan 2012 23:54:15 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-Mailman-Approved-At: Wed, 11 Jan 2012 03:08:43 -0500 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55632 Archived-At: --14dae934061b6b464204b63bf1f8 Content-Type: text/plain; charset=ISO-8859-1 The following, ugly, changes in url-http.el seem to work, based on very very very limited testing.... Basically, I changed url-http-handle-authentication so that if a change of buffer was made, it would return the new buffer, otherwise it would return nil. Then in url-http-parse-headers, I cut and pasted code for the 3XX redirect case that sets a flag for url-retrieve-synchronously to do the same thing for the 401 and 407 cases. I apologize, instead of sending patches, I am just going to attach the two new functions. (defun url-http-handle-authentication (proxy) (declare (special status success url-http-method url-http-data url-callback-function url-callback-arguments)) (url-http-debug "Handling %s authentication" (if proxy "proxy" "normal")) (let ((auths (or (nreverse (mail-fetch-field (if proxy "proxy-authenticate" "www-authenticate") nil nil t)) '("basic"))) (type nil) (url (url-recreate-url url-current-object)) (auth-url (url-recreate-url (if (and proxy (boundp 'url-http-proxy)) url-http-proxy url-current-object))) (url-basic-auth-storage (if proxy ;; Cheating, but who cares? :) 'url-http-proxy-basic-auth-storage 'url-http-real-basic-auth-storage)) auth (strength 0) (retval nil)) ;; find strongest supported auth (dolist (this-auth auths) (setq this-auth (url-eat-trailing-space (url-strip-leading-spaces this-auth))) (let* ((this-type (if (string-match "[ \t]" this-auth) (downcase (substring this-auth 0 (match-beginning 0))) (downcase this-auth))) (registered (url-auth-registered this-type)) (this-strength (cddr registered))) (when (and registered (> this-strength strength)) (setq auth this-auth type this-type strength this-strength)))) (if (not (url-auth-registered type)) (progn (widen) (goto-char (point-max)) (insert "
Sorry, but I do not know how to handle " type " authentication. If you'd like to write it," " send it to " url-bug-address ".
") (setq status t) (setq retval nil)) (let* ((args (url-parse-args (subst-char-in-string ?, ?\; auth))) (auth (url-get-authentication auth-url (cdr-safe (assoc "realm" args)) type t args))) (if (not auth) (progn (setq success t) (set retval nil)) (push (cons (if proxy "Proxy-Authorization" "Authorization") auth) url-http-extra-headers) (let ((url-request-method url-http-method) (url-request-data url-http-data) (url-request-extra-headers url-http-extra-headers) (response-buffer nil)) (setq response-buffer (url-retrieve-internal url url-callback-function url-callback-arguments)) (url-http-debug "Handling authentication return buffer is %s" response-buffer) (setq retval response-buffer))))) (url-http-debug "Handling authentication retval is %s 2:" retval) retval)) and ;; GET HERE (defun url-http-parse-headers () "Parse and handle HTTP specific headers. Return t if and only if the current buffer is still active and should be shown to the user." ;; The comments after each status code handled are taken from RFC ;; 2616 (HTTP/1.1) (declare (special url-http-end-of-headers url-http-response-status url-http-response-version url-http-method url-http-data url-http-process url-callback-function url-callback-arguments)) (url-http-mark-connection-as-free (url-host url-current-object) (url-port url-current-object) url-http-process) (if (or (not (boundp 'url-http-end-of-headers)) (not url-http-end-of-headers)) (error "Trying to parse headers in odd buffer: %s" (buffer-name))) (goto-char (point-min)) (url-http-debug "url-http-parse-headers called in (%s)" (buffer-name)) (url-http-parse-response) (mail-narrow-to-head) ;;(narrow-to-region (point-min) url-http-end-of-headers) (let ((connection (mail-fetch-field "Connection"))) ;; In HTTP 1.0, keep the connection only if there is a ;; "Connection: keep-alive" header. ;; In HTTP 1.1 (and greater), keep the connection unless there is a ;; "Connection: close" header (cond ((string= url-http-response-version "1.0") (unless (and connection (string= (downcase connection) "keep-alive")) (delete-process url-http-process))) (t (when (and connection (string= (downcase connection) "close")) (delete-process url-http-process))))) (let ((buffer (current-buffer)) (class nil) (success nil) ;; other status symbols: jewelry and luxury cars (status-symbol (cadr (assq url-http-response-status url-http-codes))) ;; The filename part of a URL could be in remote file syntax, ;; see Bug#6717 for an example. We disable file name ;; handlers, therefore. (file-name-handler-alist nil)) (setq class (/ url-http-response-status 100)) (url-http-debug "Parsed HTTP headers: class=%d status=%d" class url-http-response-status) (url-http-handle-cookies) (case class ;; Classes of response codes ;; ;; 5xx = Server Error ;; 4xx = Client Error ;; 3xx = Redirection ;; 2xx = Successful ;; 1xx = Informational (1 ; Information messages ;; 100 = Continue with request ;; 101 = Switching protocols ;; 102 = Processing (Added by DAV) (url-mark-buffer-as-dead buffer) (error "HTTP responses in class 1xx not supported (%d)" url-http-response-status)) (2 ; Success ;; 200 Ok ;; 201 Created ;; 202 Accepted ;; 203 Non-authoritative information ;; 204 No content ;; 205 Reset content ;; 206 Partial content ;; 207 Multi-status (Added by DAV) (case status-symbol ((no-content reset-content) ;; No new data, just stay at the same document (url-mark-buffer-as-dead buffer) (setq success t)) (otherwise ;; Generic success for all others. Store in the cache, and ;; mark it as successful. (widen) (if (and url-automatic-caching (equal url-http-method "GET")) (url-store-in-cache buffer)) (setq success t)))) (3 ; Redirection ;; 300 Multiple choices ;; 301 Moved permanently ;; 302 Found ;; 303 See other ;; 304 Not modified ;; 305 Use proxy ;; 307 Temporary redirect (let ((redirect-uri (or (mail-fetch-field "Location") (mail-fetch-field "URI")))) (case status-symbol (multiple-choices ; 300 ;; Quoth the spec (section 10.3.1) ;; ------------------------------- ;; The requested resource corresponds to any one of a set of ;; representations, each with its own specific location and ;; agent-driven negotiation information is being provided so ;; that the user can select a preferred representation and ;; redirect its request to that location. ;; [...] ;; If the server has a preferred choice of representation, it ;; SHOULD include the specific URI for that representation in ;; the Location field; user agents MAY use the Location field ;; value for automatic redirection. ;; ------------------------------- ;; We do not support agent-driven negotiation, so we just ;; redirect to the preferred URI if one is provided. nil) ((moved-permanently found temporary-redirect) ; 301 302 307 ;; If the 301|302 status code is received in response to a ;; request other than GET or HEAD, the user agent MUST NOT ;; automatically redirect the request unless it can be ;; confirmed by the user, since this might change the ;; conditions under which the request was issued. (unless (member url-http-method '("HEAD" "GET")) (setq redirect-uri nil))) (see-other ; 303 ;; The response to the request can be found under a different ;; URI and SHOULD be retrieved using a GET method on that ;; resource. (setq url-http-method "GET" url-http-data nil)) (not-modified ; 304 ;; The 304 response MUST NOT contain a message-body. (url-http-debug "Extracting document from cache... (%s)" (url-cache-create-filename (url-view-url t))) (url-cache-extract (url-cache-create-filename (url-view-url t))) (setq redirect-uri nil success t)) (use-proxy ; 305 ;; The requested resource MUST be accessed through the ;; proxy given by the Location field. The Location field ;; gives the URI of the proxy. The recipient is expected ;; to repeat this single request via the proxy. 305 ;; responses MUST only be generated by origin servers. (error "Redirection thru a proxy server not supported: %s" redirect-uri)) (otherwise ;; Treat everything like '300' nil)) (when redirect-uri ;; Clean off any whitespace and/or <...> cruft. (if (string-match "\\([^ \t]+\\)[ \t]" redirect-uri) (setq redirect-uri (match-string 1 redirect-uri))) (if (string-match "^<\\(.*\\)>$" redirect-uri) (setq redirect-uri (match-string 1 redirect-uri))) ;; Some stupid sites (like sourceforge) send a ;; non-fully-qualified URL (ie: /), which royally confuses ;; the URL library. (if (not (string-match url-nonrelative-link redirect-uri)) ;; Be careful to use the real target URL, otherwise we may ;; compute the redirection relative to the URL of the proxy. (setq redirect-uri (url-expand-file-name redirect-uri url-http-target-url))) (let ((url-request-method url-http-method) (url-request-data url-http-data) (url-request-extra-headers url-http-extra-headers)) ;; Check existing number of redirects (if (or (< url-max-redirections 0) (and (> url-max-redirections 0) (let ((events (car url-callback-arguments)) (old-redirects 0)) (while events (if (eq (car events) :redirect) (setq old-redirects (1+ old-redirects))) (and (setq events (cdr events)) (setq events (cdr events)))) (< old-redirects url-max-redirections)))) ;; url-max-redirections hasn't been reached, so go ;; ahead and redirect. (progn ;; Remember that the request was redirected. (setf (car url-callback-arguments) (nconc (list :redirect redirect-uri) (car url-callback-arguments))) ;; Put in the current buffer a forwarding pointer to the new ;; destination buffer. ;; FIXME: This is a hack to fix url-retrieve-synchronously ;; without changing the API. Instead url-retrieve should ;; either simply not return the "destination" buffer, or it ;; should take an optional `dest-buf' argument. (set (make-local-variable 'url-redirect-buffer) (url-retrieve-internal redirect-uri url-callback-function url-callback-arguments (url-silent url-current-object))) (url-mark-buffer-as-dead buffer)) ;; We hit url-max-redirections, so issue an error and ;; stop redirecting. (url-http-debug "Maximum redirections reached") (setf (car url-callback-arguments) (nconc (list :error (list 'error 'http-redirect-limit redirect-uri)) (car url-callback-arguments))) (setq success t)))))) (4 ; Client error ;; 400 Bad Request ;; 401 Unauthorized ;; 402 Payment required ;; 403 Forbidden ;; 404 Not found ;; 405 Method not allowed ;; 406 Not acceptable ;; 407 Proxy authentication required ;; 408 Request time-out ;; 409 Conflict ;; 410 Gone ;; 411 Length required ;; 412 Precondition failed ;; 413 Request entity too large ;; 414 Request-URI too large ;; 415 Unsupported media type ;; 416 Requested range not satisfiable ;; 417 Expectation failed ;; 422 Unprocessable Entity (Added by DAV) ;; 423 Locked ;; 424 Failed Dependency (case status-symbol (unauthorized ; 401 ;; The request requires user authentication. The response ;; MUST include a WWW-Authenticate header field containing a ;; challenge applicable to the requested resource. The ;; client MAY repeat the request with a suitable ;; Authorization header field. ;; bug patch because url-http-handle-authentication ;; might return a new buffer (let ((retval (url-http-handle-authentication nil))) (url-http-debug "Url Http Parse Headers: handling authentication return buffer TO %s" retval) (when retval ;; Put in the current buffer a forwarding pointer to the new ;; destination buffer. ;; FIXME: This is a hack to fix url-retrieve-synchronously ;; without changing the API. Instead url-retrieve should ;; either simply not return the "destination" buffer, or it ;; should take an optional `dest-buf' argument. (set (make-local-variable 'url-redirect-buffer) retval) (url-http-debug "Url Http Parse Headers: handling authentication return buffer TO %s -> %s 2:" retval url-redirect-buffer) (url-mark-buffer-as-dead buffer)))) (payment-required ; 402 ;; This code is reserved for future use (url-mark-buffer-as-dead buffer) (error "Somebody wants you to give them money")) (forbidden ; 403 ;; The server understood the request, but is refusing to ;; fulfill it. Authorization will not help and the request ;; SHOULD NOT be repeated. (setq success t)) (not-found ; 404 ;; Not found (setq success t)) (method-not-allowed ; 405 ;; The method specified in the Request-Line is not allowed ;; for the resource identified by the Request-URI. The ;; response MUST include an Allow header containing a list of ;; valid methods for the requested resource. (setq success t)) (not-acceptable ; 406 ;; The resource identified by the request is only capable of ;; generating response entities which have content ;; characteristics nota cceptable according to the accept ;; headers sent in the request. (setq success t)) (proxy-authentication-required ; 407 ;; This code is similar to 401 (Unauthorized), but indicates ;; that the client must first authenticate itself with the ;; proxy. The proxy MUST return a Proxy-Authenticate header ;; field containing a challenge applicable to the proxy for ;; the requested resource. ;; bug patch because url-http-handle-authentication ;; might return a new buffer (let ((retval (url-http-handle-authentication t))) (when retval ;; Put in the current buffer a forwarding pointer to the new ;; destination buffer. ;; FIXME: This is a hack to fix url-retrieve-synchronously ;; without changing the API. Instead url-retrieve should ;; either simply not return the "destination" buffer, or it ;; should take an optional `dest-buf' argument. (set (make-local-variable 'url-redirect-buffer) retval) (url-mark-buffer-as-dead buffer)))) (request-timeout ; 408 ;; The client did not produce a request within the time that ;; the server was prepared to wait. The client MAY repeat ;; the request without modifications at any later time. (setq success t)) (conflict ; 409 ;; The request could not be completed due to a conflict with ;; the current state of the resource. This code is only ;; allowed in situations where it is expected that the user ;; mioght be able to resolve the conflict and resubmit the ;; request. The response body SHOULD include enough ;; information for the user to recognize the source of the ;; conflict. (setq success t)) (gone ; 410 ;; The requested resource is no longer available at the ;; server and no forwarding address is known. (setq success t)) (length-required ; 411 ;; The server refuses to accept the request without a defined ;; Content-Length. The client MAY repeat the request if it ;; adds a valid Content-Length header field containing the ;; length of the message-body in the request message. ;; ;; NOTE - this will never happen because ;; `url-http-create-request' automatically calculates the ;; content-length. (setq success t)) (precondition-failed ; 412 ;; The precondition given in one or more of the ;; request-header fields evaluated to false when it was ;; tested on the server. (setq success t)) ((request-entity-too-large request-uri-too-large) ; 413 414 ;; The server is refusing to process a request because the ;; request entity|URI is larger than the server is willing or ;; able to process. (setq success t)) (unsupported-media-type ; 415 ;; The server is refusing to service the request because the ;; entity of the request is in a format not supported by the ;; requested resource for the requested method. (setq success t)) (requested-range-not-satisfiable ; 416 ;; A server SHOULD return a response with this status code if ;; a request included a Range request-header field, and none ;; of the range-specifier values in this field overlap the ;; current extent of the selected resource, and the request ;; did not include an If-Range request-header field. (setq success t)) (expectation-failed ; 417 ;; The expectation given in an Expect request-header field ;; could not be met by this server, or, if the server is a ;; proxy, the server has unambiguous evidence that the ;; request could not be met by the next-hop server. (setq success t)) (otherwise ;; The request could not be understood by the server due to ;; malformed syntax. The client SHOULD NOT repeat the ;; request without modifications. (setq success t))) ;; Tell the callback that an error occurred, and what the ;; status code was. (when success (setf (car url-callback-arguments) (nconc (list :error (list 'error 'http url-http-response-status)) (car url-callback-arguments))))) (5 ;; 500 Internal server error ;; 501 Not implemented ;; 502 Bad gateway ;; 503 Service unavailable ;; 504 Gateway time-out ;; 505 HTTP version not supported ;; 507 Insufficient storage (setq success t) (case url-http-response-status (not-implemented ; 501 ;; The server does not support the functionality required to ;; fulfill the request. nil) (bad-gateway ; 502 ;; The server, while acting as a gateway or proxy, received ;; an invalid response from the upstream server it accessed ;; in attempting to fulfill the request. nil) (service-unavailable ; 503 ;; The server is currently unable to handle the request due ;; to a temporary overloading or maintenance of the server. ;; The implication is that this is a temporary condition ;; which will be alleviated after some delay. If known, the ;; length of the delay MAY be indicated in a Retry-After ;; header. If no Retry-After is given, the client SHOULD ;; handle the response as it would for a 500 response. nil) (gateway-timeout ; 504 ;; The server, while acting as a gateway or proxy, did not ;; receive a timely response from the upstream server ;; specified by the URI (e.g. HTTP, FTP, LDAP) or some other ;; auxiliary server (e.g. DNS) it needed to access in ;; attempting to complete the request. nil) (http-version-not-supported ; 505 ;; The server does not support, or refuses to support, the ;; HTTP protocol version that was used in the request ;; message. nil) (insufficient-storage ; 507 (DAV) ;; The method could not be performed on the resource ;; because the server is unable to store the representation ;; needed to successfully complete the request. This ;; condition is considered to be temporary. If the request ;; which received this status code was the result of a user ;; action, the request MUST NOT be repeated until it is ;; requested by a separate user action. nil)) ;; Tell the callback that an error occurred, and what the ;; status code was. (when success (setf (car url-callback-arguments) (nconc (list :error (list 'error 'http url-http-response-status)) (car url-callback-arguments))))) (otherwise (error "Unknown class of HTTP response code: %d (%d)" class url-http-response-status))) (if (not success) (url-mark-buffer-as-dead buffer)) (url-http-debug "Finished parsing HTTP headers: %S" success) (widen) success)) --14dae934061b6b464204b63bf1f8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable The following, ugly, changes in url-http.el seem to work, based on very very very limited testi= ng....

Basically,

I changed url-http-handle-authentication so that if a change of= buffer was made, it would return the new buffer, otherwise it would return= nil.

Then in=A0 url-http-parse-= headers,=A0I=A0cut and pasted code for the 3XX redirect case that se= ts a flag for url-retrieve-synchronously to do the same thing for the =A040= 1 and 407 cases.

I apologize, instead of sending patches, I am just going to = attach the two new functions.

(defun url-http-handle-authentication (pro= xy)
=A0 (declare (special = status success url-http-method url-http-data
=A0 =A0url-callback-function url-callback-argume= nts))
=A0 (url-http-debug &q= uot;Handling %s authentication" (if proxy "proxy" "norm= al"))
=A0 (let ((auths (or (nreverse
=A0 =A0(mail-fetch-field
=A0 =A0 (if proxy "= ;proxy-authenticate" "www-authenticate")
=A0 =A0 nil nil t))
=A0'("basic"))= )
(type nil)
(url (url-recreate-url url-current-object= ))
(auth-url (url-recreate-url
=A0 (if (and proxy (bo= undp 'url-http-proxy))
=A0 =A0 =A0 url-http-proxy
=A0 =A0 url-current= -object)))
(url-basic-auth-storage (if prox= y
=A0 =A0;; Chea= ting, but who cares? :)
=A0 =A0'url-http-proxy-b= asic-auth-storage
=A0'url-http-real-basic-auth-storage))
auth
(strength 0)
=A0 =A0 =A0 =A0 (retva= l nil))
=A0 =A0= ;; find strongest supported auth
=A0 =A0 (dolist (this-= auth auths)
=A0 =A0 =A0 (url-strip-leading-spaces
this-auth)))
= =A0 =A0 =A0 (let* ((this-ty= pe
=A0 =A0 =A0(if (string-match &q= uot;[ \t]" this-auth)
= =A0(downcase (substring this-auth 0 (match-beginning 0)))
(downcase this-auth)))
=A0 =A0 (registered (url-au= th-registered this-type))
=A0 =A0 (this-strength (cddr re= gistered)))
(when (a= nd registered (> this-strength strength))
=A0(setq auth this-auth<= /div>
type this-type
strength this-strength))))

=A0 =A0 (if (not (url-auth-= registered type))
(p= rogn
=A0(widen)
=A0(goto-char (point-max))
=A0(insert "<hr>Sorr= y, but I do not know how to handle " type
=A0" authentication. =A0If you'd li= ke to write it,"
=A0" send it to " ur= l-bug-address ".<hr>")
=A0(setq status t)
=A0 =A0 =A0 =A0 =A0 (s= etq retval nil))
=A0 =A0 =A0 (let* ((args (url-parse-args (subst-char-in-string ?, ?\= ; auth)))
=A0 =A0 (auth (url-get-authenti= cation auth-url
= =A0 (cdr-safe (assoc "realm" args))
=A0 type t args)))
(if (not auth)
=A0 =A0 =A0 =A0 =A0 = =A0 (progn
=A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq success t)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 (set retv= al nil))
=A0(push (cons (if proxy "= Proxy-Authorization" "Authorization") auth)
url-http-extra-headers)
=A0(let ((url-request-method ur= l-http-method)
(url= -request-data url-http-data)
(url-request-extra-headers url-= http-extra-headers)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (response-buffer nil))
=A0 =A0(setq response-buffer
=A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 (url-retrieve-internal url url-callback-function
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0url-callback= -arguments))
=A0 =A0 =A0 =A0 =A0 =A0 (url-http-debug "Handling authentication re= turn buffer is %s" response-buffer)
=A0 =A0 =A0 =A0 =A0 = =A0 (setq retval response-buffer)))))
=A0 =A0 (url-http-debug "Handling authenti= cation retval is %s 2:" retval)
=A0 =A0 retval))


and

;; GET HERE
(defun url-http-parse-= headers ()
=A0"Parse and handle HTTP specific headers.
Return t if and only if the current= buffer is still active and
should be shown to the= user."
=A0 ;; The comments after each status code handled are taken from RFC
=A0 ;; 2616 (HTTP/1.1)=
=A0 (decl= are (special url-http-end-of-headers url-http-response-status
<= div> =A0 =A0url-http-response-version
=A0 =A0url-http-met= hod url-http-data url-http-process
=A0 =A0url-callback-function u= rl-callback-arguments))

=A0 (url-= http-mark-connection-as-free (url-host url-current-object)
=A0 =A0(url-port url-current-obj= ect)
=A0 =A0url-http-process)

=A0 (if (or (not (boundp &#= 39;url-http-end-of-headers))
=A0(not url-http-end-of-headers))
=A0 =A0 =A0 (error &qu= ot;Trying to parse headers in odd buffer: %s" (buffer-name)))
=A0 (goto-char (po= int-min))
=A0 (url-http-debug &q= uot;url-http-parse-headers called in (%s)" (buffer-name))
=
=A0 (url-http-parse-re= sponse)
=A0 (mail-narrow-to-he= ad)
=A0 ;;= (narrow-to-region (point-min) url-http-end-of-headers)
=A0 (let ((connection (mail-fe= tch-field "Connection")))
=A0 =A0 ;; In HTTP 1.0= , keep the connection only if there is a
=A0 =A0 ;; "Connection: keep-alive"= ; header.
=A0 =A0 ;; In HTTP 1.1= (and greater), keep the connection unless there is a
=A0 =A0 ;; "Connection: cl= ose" header
=A0 =A0 (cond
=A0 =A0 =A0((strin= g=3D url-http-response-version "1.0")
=A0 =A0 =A0 (unless (and connection
=A0 (string=3D (downcase conne= ction) "keep-alive"))
(delete-process url-http-process)))
=A0 =A0 =A0(t
=A0 =A0 =A0 (when = (and connection
(s= tring=3D (downcase connection) "close"))
(delete-process url-http-process= )))))
=A0 = (let ((buffer (current-buffer))
(class nil)
(success nil)
;; other status symbols: jewelry= and luxury cars
(st= atus-symbol (cadr (assq url-http-response-status url-http-codes)))
;; The filename part of a URL co= uld be in remote file syntax,
;; see Bug#6717 for an example. =A0We disable file name
;; handlers, therefore.
(file-name-handler-alist nil= ))
=A0 =A0 (setq class (/= url-http-response-status 100))
=A0 =A0 (url-http-debug "Parsed HTTP headers: cl= ass=3D%d status=3D%d" class url-http-response-status)
=A0 =A0 (url-http-hand= le-cookies)
=A0= =A0 (case class
=A0 =A0 =A0 ;; Classes= of response codes
=A0 =A0 =A0 ;;
=A0 =A0 =A0 ;; 5xx =3D Server Error
=A0 =A0 =A0 ;; 4xx =3D= Client Error
=A0 =A0 =A0 ;; 3xx =3D Redirection
=A0 =A0 =A0 ;; 2xx =3D Successful
=A0 =A0 =A0 ;; 1xx =3D= Informational
=A0 =A0 =A0 (1 ; Information messages
=A0 =A0 =A0 =A0;; 100 = =3D Continue with request
=A0 =A0 =A0 =A0;; 101 =3D Switching protocols
<= div>=A0 =A0 =A0 =A0;; 102 = =3D Processing (Added by DAV)
=A0 =A0 =A0 =A0(url-ma= rk-buffer-as-dead buffer)
=A0 =A0 =A0 =A0(error "HTTP responses in class 1xx not= supported (%d)" url-http-response-status))
=A0 =A0 =A0 (2 ; Success
=A0 =A0 =A0 =A0= ;; 200 Ok
=A0 =A0 =A0 =A0;; 201 = Created
= =A0 =A0 =A0 =A0;; 202 Accepted
=A0 =A0 =A0 =A0;; 203 Non-authoritative information
=A0 =A0 =A0 =A0;; 204 = No content
=A0 =A0 =A0 =A0;; 205 Reset content
=A0 =A0 =A0 =A0;; 206 Partial content
=A0 =A0 =A0 =A0;; 207 = Multi-status (Added by DAV)
=A0 =A0 =A0 =A0(case status-symbol
((no-content reset-content)
=A0;; No new data, just stay at= the same document
= =A0(url-mark-buffer-as-dead buffer)
=A0(setq success t))
(otherwise
=A0;; Generic success for all o= thers. =A0Store in the cache, and
=A0;; mark it as successful.
=A0(widen)
=A0(if (and url-automatic-caching (equa= l url-http-method "GET"))
=A0 =A0 =A0(url-store-in-cache = buffer))
<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> =A0(setq s= uccess t))))
=A0 =A0 =A0 (3 ; Redirection
=A0 =A0 =A0= =A0;; 300 Multiple choices
=A0 =A0 =A0 =A0;; 301 = Moved permanently
=A0 =A0 =A0 =A0;; 302 Found
=A0 =A0 =A0 =A0;; 303 See other
=A0 =A0 =A0 =A0;; 304 = Not modified
=A0 =A0 =A0 =A0;; 305 Use proxy
=A0 =A0 =A0 =A0;; 307 Temporary redirect
=A0 =A0 =A0 =A0(let ((= redirect-uri (or (mail-fetch-field "Location")
<= font face=3D"'courier new', monospace"> =A0 =A0 =A0 (mail-fetch-field "= ;URI"))))
(case status-symbol
=A0 (multiple-choices =A0 =A0; 300
=A0 =A0;; Quoth the spec (secti= on 10.3.1)
=A0 =A0;= ; -------------------------------
=A0 =A0;; The requested resourc= e corresponds to any one of a set of
=A0 =A0;; representations, each with its own specific loc= ation and
=A0 =A0;; agent-driven negotiat= ion information is being provided so
=A0 =A0;; that the user can select a preferred representa= tion and
=A0 =A0;; redirect its request = to that location.
= =A0 =A0;; [...]
=A0 =A0;; If the server has a p= referred choice of representation, it
=A0 =A0;; SHOULD include the specific URI for that repre= sentation in
=A0 =A0;; the Location field; u= ser agents MAY use the Location field
=A0 =A0;; value for automatic redirection.
=A0 =A0;; ---------------------= ----------
=A0 =A0;= ; We do not support agent-driven negotiation, so we just
=A0 =A0;; redirect to the prefe= rred URI if one is provided.
=A0 =A0nil)
=A0 ((moved-permanently found t= emporary-redirect) ; 301 302 307
=A0 =A0;; If the 301|302 status code is received in response = to a
=A0 =A0;; request other than GE= T or HEAD, the user agent MUST NOT
=A0 =A0;; automatically redirect the request unless it can = be
=A0 =A0;; confirmed by the user= , since this might change the
=A0 =A0;; conditions under which the request was issued.<= /div>
=A0 =A0(unless (member url-http= -method '("HEAD" "GET"))
=A0 =A0 =A0(setq redirect-uri nil)))
=A0 (see-other ; 303
=A0 =A0;; The response to the request = can be found under a different
=A0 =A0;; URI and SHOULD be ret= rieved using a GET method on that
=A0 =A0;; resource.
=A0 =A0(setq url-http-method &q= uot;GET"
=A0u= rl-http-data nil))
=A0 (not-modified ; 304
= =A0 =A0;; The 304 response MUST NOT = contain a message-body.
=A0 =A0(url-http-debug "Ex= tracting document from cache... (%s)"
=A0 =A0(url-cache-create-filename (url-view-url t= )))
=A0 =A0(url-cache-extract (url-= cache-create-filename (url-view-url t)))
=A0 =A0(setq redirect-uri nil
=A0success t))
=A0 (use-proxy ; 305
=A0 =A0;; The requested resourc= e MUST be accessed through the
=A0 =A0;; proxy given by the Location field. =A0The Location fi= eld
=A0 =A0;; gives the URI of the = proxy. =A0The recipient is expected
=A0 =A0;; to repeat this single request via the proxy. =A0= 305
=A0 =A0;; responses MUST only b= e generated by origin servers.
=A0 =A0(error "Redirection thru a proxy server not support= ed: %s"
=A0 redirect-uri))
=A0 (otherwise
=A0 =A0;; Treat everything like= '300'
=A0 = =A0nil))
(when redirect-uri
=
=A0 ;; Clean off any whitespace= and/or <...> cruft.
=A0 (if (string-match "\\(= [^ \t]+\\)[ \t]" redirect-uri)
=A0 =A0 =A0 (setq redirect-uri (match-string 1 redirect-ur= i)))
=A0 (if (string-match "^&l= t;\\(.*\\)>$" redirect-uri)
=A0 =A0 =A0 (setq redirect-uri (match-string 1 redirect-ur= i)))

= =A0 ;; Some stupid sites (like sourc= eforge) send a
=A0 ;; non-fully-qualified URL = (ie: /), which royally confuses
=A0 ;; the URL library.
=A0 (if (not (string-match url-= nonrelative-link redirect-uri))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; Be careful to use t= he real target URL, otherwise we may
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0;; compute the redirection relative to the URL of the proxy.
=A0 =A0 =A0 (setq re= direct-uri
=A0 =A0 (url-expand-file-name = redirect-uri url-http-target-url)))
=A0 =A0 =A0 =A0 =A0 =A0(let ((url-request-method = url-http-method)
(url-request-data url-http-dat= a)
(url-request-ex= tra-headers url-http-extra-headers))
=A0 =A0 ;; Check existing numbe= r of redirects
=A0 = =A0 (if (or (< url-max-redirections 0)
=A0 =A0 (and (> url-max-red= irections 0)
=A0(= let ((events (car url-callback-arguments))
(old-redirects 0))
=A0 =A0(while events=
=A0 =A0 =A0(if (eq (car event= s) :redirect)
= =A0(setq old-redirects (1+ old-redirects)))
=A0 =A0 =A0(and (setq events = (cdr events))
= =A0 (setq events (cdr events))))
=A0 =A0(< old-redirects ur= l-max-redirections))))
;; url-max-redirections hasn't been reached, so go
;; ahead and redirect.<= /div>
(progn
=A0 ;; Remember that the reque= st was redirected.
= =A0 (setf (car url-callback-arguments)
(nconc (list :redirect redire= ct-uri)
(car url-= callback-arguments)))
=A0 ;; Put in the current buff= er a forwarding pointer to the new
=A0 ;; destination buffer.
=A0 ;; FIXME: This is a hack t= o fix url-retrieve-synchronously
=A0 ;; without changing the API. =A0Instead url-retrieve sho= uld
=A0 ;; either simply not retur= n the "destination" buffer, or it
=A0 ;; should take an optional `dest-buf' arg= ument.
=A0 (set (make-local-variable = 'url-redirect-buffer)
= (url-retrieve-internal
redirect-uri url-callback-fun= ction
url-callbac= k-arguments
(url-silent url-current-objec= t)))
=A0 (url-mark= -buffer-as-dead buffer))
=A0 =A0 =A0 ;; We hit url-max-r= edirections, so issue an error and
=A0 =A0 =A0 ;; stop redirecting.
=A0 =A0 =A0 (url-http-debug &qu= ot;Maximum redirections reached")
=A0 =A0 =A0 (setf (car url-callback-arguments)
=A0 =A0 (nconc (list :error (l= ist 'error 'http-redirect-limit
=A0 =A0 =A0 redirect-uri))
=A0 =A0(car url-callback-argu= ments)))
<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> =A0 =A0 = =A0 (setq success t))))))
=A0 =A0 =A0 (4 ; Client error<= /font>
=A0 =A0 = =A0 =A0;; 400 Bad Request
=A0 =A0 =A0 =A0;; 401 = Unauthorized
=A0 =A0 =A0 =A0;; 402 Payment required
=A0 =A0 =A0 =A0;; 403 Forbidden
=A0 =A0 =A0 =A0;; 404 = Not found
= =A0 =A0 =A0 =A0;; 405 Method not allowed
=A0 =A0 =A0 =A0;; 406 Not acceptable<= /div>
=A0 =A0 =A0 =A0;; 407 = Proxy authentication required
=A0 =A0 =A0 =A0;; 408 Request time-out
=A0 =A0 =A0 =A0;; 409 Conf= lict
=A0 =A0 =A0 =A0;; 410 = Gone
=A0 = =A0 =A0 =A0;; 411 Length required
=A0 =A0 =A0 =A0;; 412 Precondition failed
=A0 =A0 =A0 =A0;; 413 = Request entity too large
=A0 =A0 =A0 =A0;; 414 Request-URI too large
=A0 =A0 =A0 =A0;; 415 Unsu= pported media type
=A0 =A0 =A0 =A0;; 416 = Requested range not satisfiable
=A0 =A0 =A0 =A0;; 417 Expectation failed
=
=A0 =A0 =A0 =A0;; 422 = Unprocessable Entity (Added by DAV)
=A0 =A0 =A0 =A0;; 423 = Locked
=A0= =A0 =A0 =A0;; 424 Failed Dependency
=A0 =A0 =A0 =A0(case status-symbol
(unauthorized ; 401
=A0;; The request requires user authent= ication. =A0The response
=A0;; MUST include a WWW-Authen= ticate header field containing a
=A0;; challenge applicable to the requested resource. =A0The<= /font>
=A0;; client MAY repeat the req= uest with a suitable
=A0;; Authorization header field.

= =A0 =A0 =A0 =A0 =A0 ;; bug = patch because url-http-handle-authentication
=A0 =A0 =A0 =A0 =A0 ;; might return a ne= w buffer

= =A0 =A0 =A0 =A0 =A0 (let ((= retval (url-http-handle-authentication nil)))
=A0 =A0 =A0 =A0 =A0 =A0 (url-http-deb= ug "Url Http Parse Headers: handling authentication return buffer TO %= s" retval)
=A0 =A0 =A0 =A0 =A0 = =A0 (when retval
=A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; Put in the current buffer a forwardin= g pointer to the new
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 ;; destination buffer.
=A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; FIXME: This is a hack t= o fix url-retrieve-synchronously
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 ;; without changing the API. =A0Instead url-retrieve should<= /div>
=A0 =A0 =A0 =A0 = =A0 =A0 =A0 ;; either simply not return the "destination" buffer,= or it
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 ;; should take an optional `dest-buf' argument.
=A0 =A0 =A0 =A0 =A0 =A0 = =A0 (set (make-local-variable 'url-redirect-buffer)
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0retval)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 (url-http-debug "Url Http= Parse Headers: handling authentication return buffer TO %s -> %s 2:&quo= t;
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 retval url-redirect-buffer)<= /div>
=A0 =A0 =A0 =A0 = =A0 =A0 =A0 (url-mark-buffer-as-dead buffer))))
=A0 =A0 =A0 =A0 =A0
(payment-required = =A0 =A0 =A0 =A0 =A0 =A0 =A0; 402
=A0;; This code is reserved for= future use
=A0(url= -mark-buffer-as-dead buffer)
=A0(error "Somebody wants = you to give them money"))
(forbidden ; 403
=A0;; The server understood the= request, but is refusing to
=A0;; fulfill it. =A0Authorization will not help and the request<= /font>
=A0;; SHOULD NOT be repeated.
=A0(setq success t))=
(not-found ; 404
=A0;; Not found
=A0(setq success t))
(method-not-allowed ; 405
=A0;; The method specified in t= he Request-Line is not allowed
=A0;; for the resource identified by the Request-URI. =A0The
=A0;; response MUST include an = Allow header containing a list of
=A0;; valid methods for the requested resource.
=A0(setq success t))
(not-acceptable ; 406
=A0;; The resource identified b= y the request is only capable of
=A0;; generating response entities which have content<= /div>
=A0;; characteristics nota ccep= table according to the accept
=A0;; headers sent in the request.
=A0(setq success t))
(proxy-authentication-require= d ; 407
=A0;; This code is similar to 4= 01 (Unauthorized), but indicates
=A0;; that the client must first authenticate itself with the=
=A0;; proxy. =A0The proxy MUST = return a Proxy-Authenticate header
=A0;; field containing a challenge applicable to the proxy = for
=A0;; the requested resource.

=
=A0 =A0 =A0 =A0 =A0 ;;= bug patch because url-http-handle-authentication
=A0 =A0 =A0 =A0 =A0 ;; might return= a new buffer
=A0 =A0 =A0 =A0 =A0=A0=
=A0 =A0 = =A0 =A0 =A0 (let ((retval (url-http-handle-authentication t)))
=
=A0 =A0 =A0 =A0 =A0=A0=
=A0 =A0 =A0 =A0 =A0 = =A0 (when retval
=A0 =A0 =A0 =A0 =A0 =A0 ;; Put in the current buffer a forwarding po= inter to the new
=A0 ;; destination buffer.
=A0 ;; FIXME: This = is a hack to fix url-retrieve-synchronously
=A0 ;; without changing the AP= I. =A0Instead url-retrieve should
=A0 ;; either simply not return the "destination"= buffer, or it
=A0 ;; should take an optional= `dest-buf' argument.
= =A0 (set (make-local-variable 'url-redirect-buffer)
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 retval)
=A0 (url-mark-buffer-as-dead buffer))))
=A0 =A0 =A0 =A0 =A0=A0=
(request-timeout ; 408
=A0;; The client did not produc= e a request within the time that
=A0;; the server was prepared to wait. =A0The client MAY repe= at
=A0;; the request without modif= ications at any later time.
= =A0(setq success t))
(conflict ; 409
=A0;; The request could not be completed du= e to a conflict with
=A0;; the current state of the = resource. =A0This code is only
=A0;; allowed in situations where it is expected that the user<= /font>
=A0;; mioght be able to resolve= the conflict and resubmit the
=A0;; request. =A0The response body SHOULD include enough
=A0;; information for the user = to recognize the source of the
=A0;; conflict.
=A0(setq success t))
(gone =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0; 410
=A0;; The requested resource is= no longer available at the
= =A0;; server and no forwarding address is known.
=A0(setq success t))
(length-required ; 411
=A0;; The server refuses to acc= ept the request without a defined
=A0;; Content-Length. =A0The client MAY repeat the request i= f it
=A0;; adds a valid Content-Leng= th header field containing the
=A0;; length of the message-body in the request message.=
=A0;;
=A0;; NOTE - this will never happen because<= /font>
=A0;; `url-http-create-request&= #39; automatically calculates the
=A0;; content-length.
=A0(setq success t))
(precondition-failed ; 412
=A0;; The precondition given in= one or more of the
= =A0;; request-header fields evaluated to false when it was
=A0;; tested on the server.
=A0(setq success t))=
((request-entity-too-large requ= est-uri-too-large) ; 413 414
=A0;; The server is refusing to process a request because the
=A0;; request entity|URI is lar= ger than the server is willing or
=A0;; able to process.
=A0(setq success t))
(unsupported-media-type ; 415
=A0;; The server is refusing to= service the request because the
=A0;; entity of the request is in a format not supported by t= he
=A0;; requested resource for th= e requested method.
= =A0(setq success t))
(requested-range-not-satisfiabl= e ; 416
=A0;; A ser= ver SHOULD return a response with this status code if
=A0;; a request included a Rang= e request-header field, and none
=A0;; of the range-specifier values in this field overlap the=
=A0;; current extent of the sel= ected resource, and the request
=A0;; did not include an If-Range request-header field.=
=A0(setq success t))
(expectation-failed ; 417
=A0;; The expectation given in = an Expect request-header field
=A0;; could not be met by this server, or, if the server is a
=A0;; proxy, the server has una= mbiguous evidence that the
= =A0;; request could not be met by the next-hop server.
=A0(setq success t))
(otherwise
=A0;; The request could not be = understood by the server due to
=A0;; malformed syntax. =A0The client SHOULD NOT repeat the
=A0;; request without modificat= ions.
=A0(setq succ= ess t)))
=A0 =A0 =A0 =A0;; Tell= the callback that an error occurred, and what the
=A0 =A0 =A0 =A0;; status code was.=
=A0 =A0 =A0 =A0(when succes= s
(setf (car url-ca= llback-arguments)
=A0 =A0 =A0 (nconc (list :error= (list 'error 'http url-http-response-status))
=A0 =A0 =A0(car url-callback-arguments= )))))
=A0 =A0 =A0 (5<= /div>
=A0 =A0 =A0 =A0;;= 500 Internal server error
=A0 =A0 =A0 =A0;; 501 Not implemented
=A0 =A0 =A0 =A0;; 502 = Bad gateway
=A0 =A0 =A0 =A0;; 504 Gateway time-out
=A0 =A0 =A0 =A0;; 505 = HTTP version not supported
=A0 =A0 =A0 =A0;; 507 Insufficient storage
=A0 =A0 =A0 =A0(setq succ= ess t)
=A0 =A0 =A0 =A0(case u= rl-http-response-status
(not-implemented ; 501
=A0;; The server does not suppo= rt the functionality required to
=A0;; fulfill the request.
=A0nil)
(bad-gateway ; 502
=A0;; The server, while acting = as a gateway or proxy, received
=A0;; an invalid response from the upstream server it accessed=
=A0;; in attempting to fulfill = the request.
=A0nil= )
(service-unavailable ; 503
=A0;; The server is currently una= ble to handle the request due
=A0;; to a temporary overloadin= g or maintenance of the server.
=A0;; The implication is that this is a temporary condition
=A0;; which will be alleviated = after some delay. =A0If known, the
=A0;; length of the delay MAY be indicated in a Retry-After=
=A0;; header. =A0If no Retry-Af= ter is given, the client SHOULD
=A0;; handle the response as it would for a 500 response.
=A0nil)
(gateway-timeout ; 504
=A0;; The server, while acting = as a gateway or proxy, did not
=A0;; receive a timely response from the upstream server=
=A0;; specified by the URI (e.g= . HTTP, FTP, LDAP) or some other
=A0;; auxiliary server (e.g. DNS) it needed to access in
=A0;; attempting to complete th= e request.
=A0nil)<= /font>
(http-version-not-supported ; 505
=A0;; The server does not support, o= r refuses to support, the
<= /span> =A0;; HTTP protocol version that was used in the request
=A0;; message.
=A0nil)
(insufficient-storage ; 507 (DAV)<= /div>
=A0;; The method could not be perfor= med on the resource
= =A0;; because the server is unable to store the representation
=A0;; needed to successfully co= mplete the request. =A0This
= =A0;; condition is considered to be temporary. =A0If the request
=A0;; which received this statu= s code was the result of a user
=A0;; action, the request MUST NOT be repeated until it is
=A0;; requested by a separate u= ser action.
=A0nil)= )
=A0 =A0 =A0 =A0;; Tell= the callback that an error occurred, and what the
=A0 =A0 =A0 =A0;; status code was.=
=A0 =A0 =A0 =A0(when succes= s
(setf (car url-ca= llback-arguments)
=A0 =A0 =A0 (nconc (list :error= (list 'error 'http url-http-response-status))
=A0 =A0 =A0(car url-callback-arguments= )))))
=A0 =A0 =A0 (otherwise=
=A0 =A0 = =A0 =A0(error "Unknown class of HTTP response code: %d (%d)"
=A0 =A0 =A0class url-ht= tp-response-status)))
=A0 =A0 (if (not succe= ss)
(url-mark-buffer= -as-dead buffer))
=A0 =A0 (url-http-debu= g "Finished parsing HTTP headers: %S" success)
<= font face=3D"'courier new', monospace">=A0 =A0 (widen)
=
=A0 =A0 success))



--14dae934061b6b464204b63bf1f8--