aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-11-18 16:55:54 +0000
committerStefan Monnier2005-11-18 16:55:54 +0000
commit12f1edc8231e119616a4d649db26672c74466c30 (patch)
tree6b4065712b7540d9e8845e99929d898a5e365924
parent35af34900fadf103448c47c726f2f9315572c115 (diff)
downloademacs-12f1edc8231e119616a4d649db26672c74466c30.tar.gz
emacs-12f1edc8231e119616a4d649db26672c74466c30.zip
Use with-current-buffer.
(url-http-target-url): Rename from url-http-cookies-sources. (url-http-parse-headers): Use it. (url-http-handle-authentication): Use subst-char-in-string.
-rw-r--r--lisp/url/ChangeLog7
-rw-r--r--lisp/url/url-http.el52
2 files changed, 28 insertions, 31 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index e0a68349ce1..9a8c8955fc5 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,10 @@
12005-11-18 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * url-http.el: Use with-current-buffer.
4 (url-http-target-url): Rename from url-http-cookies-sources.
5 (url-http-parse-headers): Use it.
6 (url-http-handle-authentication): Use subst-char-in-string.
7
12005-11-16 Juergen Hoetzel <emacs@hoetzel.info> (tiny change) 82005-11-16 Juergen Hoetzel <emacs@hoetzel.info> (tiny change)
2 9
3 * url-handlers.el (url-insert-file-contents): Use the charset info 10 * url-handlers.el (url-insert-file-contents): Use the charset info
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 39db321c080..725f4bc1c8a 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -26,10 +26,9 @@
26 26
27;;; Code: 27;;; Code:
28 28
29(eval-when-compile 29(eval-when-compile (require 'cl))
30 (require 'cl) 30(defvar url-http-extra-headers)
31 (defvar url-http-extra-headers) 31(defvar url-http-target-url)
32 (defvar url-http-cookies-sources))
33(require 'url-gw) 32(require 'url-gw)
34(require 'url-util) 33(require 'url-util)
35(require 'url-parse) 34(require 'url-parse)
@@ -320,16 +319,9 @@ This allows us to use `mail-fetch-field', etc."
320 " authentication. If you'd like to write it," 319 " authentication. If you'd like to write it,"
321 " send it to " url-bug-address ".<hr>") 320 " send it to " url-bug-address ".<hr>")
322 (setq status t)) 321 (setq status t))
323 (let* ((args auth) 322 (let* ((args (url-parse-args (subst-char-in-string ?, ?\; auth)))
324 (ctr (1- (length args))) 323 (auth (url-get-authentication url (cdr-safe (assoc "realm" args))
325 auth) 324 type t args)))
326 (while (/= 0 ctr)
327 (if (char-equal ?, (aref args ctr))
328 (aset args ctr ?\;))
329 (setq ctr (1- ctr)))
330 (setq args (url-parse-args args)
331 auth (url-get-authentication url (cdr-safe (assoc "realm" args))
332 type t args))
333 (if (not auth) 325 (if (not auth)
334 (setq success t) 326 (setq success t)
335 (push (cons (if proxy "Proxy-Authorization" "Authorization") auth) 327 (push (cons (if proxy "Proxy-Authorization" "Authorization") auth)
@@ -358,7 +350,7 @@ The buffer must already be narrowed to the headers, so mail-fetch-field will
358work correctly." 350work correctly."
359 (let ((cookies (mail-fetch-field "Set-Cookie" nil nil t)) 351 (let ((cookies (mail-fetch-field "Set-Cookie" nil nil t))
360 (cookies2 (mail-fetch-field "Set-Cookie2" nil nil t)) 352 (cookies2 (mail-fetch-field "Set-Cookie2" nil nil t))
361 (url-current-object url-http-cookies-sources)) 353 (url-current-object url-http-target-url))
362 (and cookies (url-http-debug "Found %d Set-Cookie headers" (length cookies))) 354 (and cookies (url-http-debug "Found %d Set-Cookie headers" (length cookies)))
363 (and cookies2 (url-http-debug "Found %d Set-Cookie2 headers" (length cookies2))) 355 (and cookies2 (url-http-debug "Found %d Set-Cookie2 headers" (length cookies2)))
364 (while cookies 356 (while cookies
@@ -510,8 +502,11 @@ should be shown to the user."
510 ;; non-fully-qualified URL (ie: /), which royally confuses 502 ;; non-fully-qualified URL (ie: /), which royally confuses
511 ;; the URL library. 503 ;; the URL library.
512 (if (not (string-match url-nonrelative-link redirect-uri)) 504 (if (not (string-match url-nonrelative-link redirect-uri))
513 (setq redirect-uri (url-expand-file-name redirect-uri))) 505 ;; Be careful to use the real target URL, otherwise we may
514 (let ((url-request-method url-http-method) 506 ;; compute the redirection relative to the URL of the proxy.
507 (setq redirect-uri
508 (url-expand-file-name redirect-uri url-http-target-url)))
509 (let ((url-request-method url-http-method)
515 (url-request-data url-http-data) 510 (url-request-data url-http-data)
516 (url-request-extra-headers url-http-extra-headers)) 511 (url-request-extra-headers url-http-extra-headers))
517 (url-retrieve redirect-uri url-callback-function 512 (url-retrieve redirect-uri url-callback-function
@@ -727,8 +722,7 @@ should be shown to the user."
727 (url-http-debug "url-http-end-of-document-sentinel in buffer (%s)" 722 (url-http-debug "url-http-end-of-document-sentinel in buffer (%s)"
728 (process-buffer proc)) 723 (process-buffer proc))
729 (url-http-idle-sentinel proc why) 724 (url-http-idle-sentinel proc why)
730 (save-excursion 725 (with-current-buffer (process-buffer proc)
731 (set-buffer (process-buffer proc))
732 (goto-char (point-min)) 726 (goto-char (point-min))
733 (if (not (looking-at "HTTP/")) 727 (if (not (looking-at "HTTP/"))
734 ;; HTTP/0.9 just gets passed back no matter what 728 ;; HTTP/0.9 just gets passed back no matter what
@@ -1039,8 +1033,7 @@ CBARGS as the arguments."
1039 (setq buffer nil) 1033 (setq buffer nil)
1040 (error "Could not create connection to %s:%d" (url-host url) 1034 (error "Could not create connection to %s:%d" (url-host url)
1041 (url-port url))) 1035 (url-port url)))
1042 (save-excursion 1036 (with-current-buffer buffer
1043 (set-buffer buffer)
1044 (mm-disable-multibyte) 1037 (mm-disable-multibyte)
1045 (setq url-current-object url 1038 (setq url-current-object url
1046 mode-line-format "%b [%s]") 1039 mode-line-format "%b [%s]")
@@ -1060,7 +1053,7 @@ CBARGS as the arguments."
1060 url-http-method 1053 url-http-method
1061 url-http-extra-headers 1054 url-http-extra-headers
1062 url-http-data 1055 url-http-data
1063 url-http-cookies-sources)) 1056 url-http-target-url))
1064 (set (make-local-variable var) nil)) 1057 (set (make-local-variable var) nil))
1065 1058
1066 (setq url-http-method (or url-request-method "GET") 1059 (setq url-http-method (or url-request-method "GET")
@@ -1073,9 +1066,9 @@ CBARGS as the arguments."
1073 url-callback-function callback 1066 url-callback-function callback
1074 url-callback-arguments cbargs 1067 url-callback-arguments cbargs
1075 url-http-after-change-function 'url-http-wait-for-headers-change-function 1068 url-http-after-change-function 'url-http-wait-for-headers-change-function
1076 url-http-cookies-sources (if (boundp 'proxy-object) 1069 url-http-target-url (if (boundp 'proxy-object)
1077 proxy-object 1070 proxy-object
1078 url-current-object)) 1071 url-current-object))
1079 1072
1080 (set-process-buffer connection buffer) 1073 (set-process-buffer connection buffer)
1081 (set-process-sentinel connection 'url-http-end-of-document-sentinel) 1074 (set-process-sentinel connection 'url-http-end-of-document-sentinel)
@@ -1096,8 +1089,7 @@ CBARGS as the arguments."
1096 (declare (special url-http-after-change-function)) 1089 (declare (special url-http-after-change-function))
1097 (and (process-buffer proc) 1090 (and (process-buffer proc)
1098 (/= (length data) 0) 1091 (/= (length data) 0)
1099 (save-excursion 1092 (with-current-buffer (process-buffer proc)
1100 (set-buffer (process-buffer proc))
1101 (url-http-debug "Calling after change function `%s' for `%S'" url-http-after-change-function proc) 1093 (url-http-debug "Calling after change function `%s' for `%S'" url-http-after-change-function proc)
1102 (funcall url-http-after-change-function 1094 (funcall url-http-after-change-function
1103 (point-max) 1095 (point-max)
@@ -1114,8 +1106,7 @@ CBARGS as the arguments."
1114 (defun url-http-symbol-value-in-buffer (symbol buffer 1106 (defun url-http-symbol-value-in-buffer (symbol buffer
1115 &optional unbound-value) 1107 &optional unbound-value)
1116 "Return the value of SYMBOL in BUFFER, or UNBOUND-VALUE if it is unbound." 1108 "Return the value of SYMBOL in BUFFER, or UNBOUND-VALUE if it is unbound."
1117 (save-excursion 1109 (with-current-buffer buffer
1118 (set-buffer buffer)
1119 (if (not (boundp symbol)) 1110 (if (not (boundp symbol))
1120 unbound-value 1111 unbound-value
1121 (symbol-value symbol)))) 1112 (symbol-value symbol))))
@@ -1198,10 +1189,9 @@ p3p
1198 (when (and buffer (= 2 (/ (url-http-symbol-value-in-buffer 1189 (when (and buffer (= 2 (/ (url-http-symbol-value-in-buffer
1199 'url-http-response-status buffer 0) 100))) 1190 'url-http-response-status buffer 0) 100)))
1200 ;; Only parse the options if we got a 2xx response code! 1191 ;; Only parse the options if we got a 2xx response code!
1201 (save-excursion 1192 (with-current-buffer buffer
1202 (save-restriction 1193 (save-restriction
1203 (save-match-data 1194 (save-match-data
1204 (set-buffer buffer)
1205 (mail-narrow-to-head) 1195 (mail-narrow-to-head)
1206 1196
1207 ;; Figure out what methods are supported. 1197 ;; Figure out what methods are supported.