diff options
| author | Magnus Henoch | 2006-12-08 00:38:47 +0000 |
|---|---|---|
| committer | Magnus Henoch | 2006-12-08 00:38:47 +0000 |
| commit | 9450f1246a4496c4ce464c96ca5c3695cd42e703 (patch) | |
| tree | c1a0c981c69ee6fc383b838589b1773677aeeaee | |
| parent | 3a15c71bb831c45544364b5af2164cafcc1842c1 (diff) | |
| download | emacs-9450f1246a4496c4ce464c96ca5c3695cd42e703.tar.gz emacs-9450f1246a4496c4ce464c96ca5c3695cd42e703.zip | |
(url-http-create-request): Remove url argument, use the buffer-local
variable `url-http-target-url' instead. Both callers updated.
Simplify proxy handling.
(url-http): Don't make proxy-object buffer local.
| -rw-r--r-- | lisp/url/url-http.el | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index ad556c30a07..309be690408 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el | |||
| @@ -149,31 +149,32 @@ request.") | |||
| 149 | (concat " (" (or url-system-type url-os-type) ")")) | 149 | (concat " (" (or url-system-type url-os-type) ")")) |
| 150 | (t ""))))) | 150 | (t ""))))) |
| 151 | 151 | ||
| 152 | (defun url-http-create-request (url &optional ref-url) | 152 | (defun url-http-create-request (&optional ref-url) |
| 153 | "Create an HTTP request for URL, referred to by REF-URL." | 153 | "Create an HTTP request for `url-http-target-url', referred to by REF-URL." |
| 154 | (declare (special proxy-object proxy-info | 154 | (declare (special proxy-info |
| 155 | url-http-method url-http-data | 155 | url-http-method url-http-data |
| 156 | url-http-extra-headers)) | 156 | url-http-extra-headers)) |
| 157 | (url-http-debug "url-proxy-object is %s\n" url-proxy-object) | ||
| 157 | (let* ((extra-headers) | 158 | (let* ((extra-headers) |
| 158 | (request nil) | 159 | (request nil) |
| 159 | (no-cache (cdr-safe (assoc "Pragma" url-http-extra-headers))) | 160 | (no-cache (cdr-safe (assoc "Pragma" url-http-extra-headers))) |
| 160 | (proxy-obj (and (boundp 'proxy-object) proxy-object)) | 161 | (using-proxy (not (eq url-current-object url-http-target-url))) |
| 161 | (proxy-auth (if (or (cdr-safe (assoc "Proxy-Authorization" | 162 | (proxy-auth (if (or (cdr-safe (assoc "Proxy-Authorization" |
| 162 | url-http-extra-headers)) | 163 | url-http-extra-headers)) |
| 163 | (not proxy-obj)) | 164 | (not using-proxy)) |
| 164 | nil | 165 | nil |
| 165 | (let ((url-basic-auth-storage | 166 | (let ((url-basic-auth-storage |
| 166 | 'url-http-proxy-basic-auth-storage)) | 167 | 'url-http-proxy-basic-auth-storage)) |
| 167 | (url-get-authentication url nil 'any nil)))) | 168 | (url-get-authentication url-http-target-url nil 'any nil)))) |
| 168 | (real-fname (concat (url-filename (or proxy-obj url)) | 169 | (real-fname (concat (url-filename url-http-target-url) |
| 169 | (url-recreate-url-attributes (or proxy-obj url)))) | 170 | (url-recreate-url-attributes url-http-target-url))) |
| 170 | (host (url-host (or proxy-obj url))) | 171 | (host (url-host url-http-target-url)) |
| 171 | (auth (if (cdr-safe (assoc "Authorization" url-http-extra-headers)) | 172 | (auth (if (cdr-safe (assoc "Authorization" url-http-extra-headers)) |
| 172 | nil | 173 | nil |
| 173 | (url-get-authentication (or | 174 | (url-get-authentication (or |
| 174 | (and (boundp 'proxy-info) | 175 | (and (boundp 'proxy-info) |
| 175 | proxy-info) | 176 | proxy-info) |
| 176 | url) nil 'any nil)))) | 177 | url-http-target-url) nil 'any nil)))) |
| 177 | (if (equal "" real-fname) | 178 | (if (equal "" real-fname) |
| 178 | (setq real-fname "/")) | 179 | (setq real-fname "/")) |
| 179 | (setq no-cache (and no-cache (string-match "no-cache" no-cache))) | 180 | (setq no-cache (and no-cache (string-match "no-cache" no-cache))) |
| @@ -222,12 +223,12 @@ request.") | |||
| 222 | (list | 223 | (list |
| 223 | ;; The request | 224 | ;; The request |
| 224 | (or url-http-method "GET") " " | 225 | (or url-http-method "GET") " " |
| 225 | (if proxy-obj (url-recreate-url proxy-obj) real-fname) | 226 | (if using-proxy (url-recreate-url url-http-target-url) real-fname) |
| 226 | " HTTP/" url-http-version "\r\n" | 227 | " HTTP/" url-http-version "\r\n" |
| 227 | ;; Version of MIME we speak | 228 | ;; Version of MIME we speak |
| 228 | "MIME-Version: 1.0\r\n" | 229 | "MIME-Version: 1.0\r\n" |
| 229 | ;; (maybe) Try to keep the connection open | 230 | ;; (maybe) Try to keep the connection open |
| 230 | "Connection: " (if (or proxy-obj | 231 | "Connection: " (if (or using-proxy |
| 231 | (not url-http-attempt-keepalives)) | 232 | (not url-http-attempt-keepalives)) |
| 232 | "close" "keep-alive") "\r\n" | 233 | "close" "keep-alive") "\r\n" |
| 233 | ;; HTTP extensions we support | 234 | ;; HTTP extensions we support |
| @@ -235,11 +236,11 @@ request.") | |||
| 235 | (format | 236 | (format |
| 236 | "Extension: %s\r\n" url-extensions-header)) | 237 | "Extension: %s\r\n" url-extensions-header)) |
| 237 | ;; Who we want to talk to | 238 | ;; Who we want to talk to |
| 238 | (if (/= (url-port (or proxy-obj url)) | 239 | (if (/= (url-port url-http-target-url) |
| 239 | (url-scheme-get-property | 240 | (url-scheme-get-property |
| 240 | (url-type (or proxy-obj url)) 'default-port)) | 241 | (url-type url-http-target-url) 'default-port)) |
| 241 | (format | 242 | (format |
| 242 | "Host: %s:%d\r\n" host (url-port (or proxy-obj url))) | 243 | "Host: %s:%d\r\n" host (url-port url-http-target-url)) |
| 243 | (format "Host: %s\r\n" host)) | 244 | (format "Host: %s\r\n" host)) |
| 244 | ;; Who its from | 245 | ;; Who its from |
| 245 | (if url-personal-mail-address | 246 | (if url-personal-mail-address |
| @@ -266,11 +267,11 @@ request.") | |||
| 266 | auth | 267 | auth |
| 267 | ;; Cookies | 268 | ;; Cookies |
| 268 | (url-cookie-generate-header-lines host real-fname | 269 | (url-cookie-generate-header-lines host real-fname |
| 269 | (equal "https" (url-type url))) | 270 | (equal "https" (url-type url-http-target-url))) |
| 270 | ;; If-modified-since | 271 | ;; If-modified-since |
| 271 | (if (and (not no-cache) | 272 | (if (and (not no-cache) |
| 272 | (member url-http-method '("GET" nil))) | 273 | (member url-http-method '("GET" nil))) |
| 273 | (let ((tm (url-is-cached (or proxy-obj url)))) | 274 | (let ((tm (url-is-cached url-http-target-url))) |
| 274 | (if tm | 275 | (if tm |
| 275 | (concat "If-modified-since: " | 276 | (concat "If-modified-since: " |
| 276 | (url-get-normalized-date tm) "\r\n")))) | 277 | (url-get-normalized-date tm) "\r\n")))) |
| @@ -1085,8 +1086,7 @@ CBARGS as the arguments." | |||
| 1085 | url-http-chunked-length | 1086 | url-http-chunked-length |
| 1086 | url-http-chunked-start | 1087 | url-http-chunked-start |
| 1087 | url-http-chunked-counter | 1088 | url-http-chunked-counter |
| 1088 | url-http-process | 1089 | url-http-process)) |
| 1089 | proxy-object)) | ||
| 1090 | (let ((connection (url-http-find-free-connection (url-host url) | 1090 | (let ((connection (url-http-find-free-connection (url-host url) |
| 1091 | (url-port url))) | 1091 | (url-port url))) |
| 1092 | (buffer (generate-new-buffer (format " *http %s:%d*" | 1092 | (buffer (generate-new-buffer (format " *http %s:%d*" |
| @@ -1122,7 +1122,6 @@ CBARGS as the arguments." | |||
| 1122 | url-http-data | 1122 | url-http-data |
| 1123 | url-http-target-url)) | 1123 | url-http-target-url)) |
| 1124 | (set (make-local-variable var) nil)) | 1124 | (set (make-local-variable var) nil)) |
| 1125 | (make-local-variable 'proxy-object) | ||
| 1126 | 1125 | ||
| 1127 | (setq url-http-method (or url-request-method "GET") | 1126 | (setq url-http-method (or url-request-method "GET") |
| 1128 | url-http-extra-headers url-request-extra-headers | 1127 | url-http-extra-headers url-request-extra-headers |
| @@ -1134,9 +1133,8 @@ CBARGS as the arguments." | |||
| 1134 | url-callback-function callback | 1133 | url-callback-function callback |
| 1135 | url-callback-arguments cbargs | 1134 | url-callback-arguments cbargs |
| 1136 | url-http-after-change-function 'url-http-wait-for-headers-change-function | 1135 | url-http-after-change-function 'url-http-wait-for-headers-change-function |
| 1137 | url-http-target-url (if (boundp 'proxy-object) | 1136 | url-http-target-url (or url-proxy-object |
| 1138 | proxy-object | 1137 | url-current-object)) |
| 1139 | url-current-object)) | ||
| 1140 | 1138 | ||
| 1141 | (set-process-buffer connection buffer) | 1139 | (set-process-buffer connection buffer) |
| 1142 | (set-process-filter connection 'url-http-generic-filter) | 1140 | (set-process-filter connection 'url-http-generic-filter) |
| @@ -1151,7 +1149,7 @@ CBARGS as the arguments." | |||
| 1151 | (url-port url))) | 1149 | (url-port url))) |
| 1152 | (t | 1150 | (t |
| 1153 | (set-process-sentinel connection 'url-http-end-of-document-sentinel) | 1151 | (set-process-sentinel connection 'url-http-end-of-document-sentinel) |
| 1154 | (process-send-string connection (url-http-create-request url))))))) | 1152 | (process-send-string connection (url-http-create-request))))))) |
| 1155 | buffer)) | 1153 | buffer)) |
| 1156 | 1154 | ||
| 1157 | (defun url-http-async-sentinel (proc why) | 1155 | (defun url-http-async-sentinel (proc why) |
| @@ -1162,7 +1160,7 @@ CBARGS as the arguments." | |||
| 1162 | (cond | 1160 | (cond |
| 1163 | ((string= (substring why 0 4) "open") | 1161 | ((string= (substring why 0 4) "open") |
| 1164 | (set-process-sentinel proc 'url-http-end-of-document-sentinel) | 1162 | (set-process-sentinel proc 'url-http-end-of-document-sentinel) |
| 1165 | (process-send-string proc (url-http-create-request url-http-target-url))) | 1163 | (process-send-string proc (url-http-create-request))) |
| 1166 | (t | 1164 | (t |
| 1167 | (setf (car url-callback-arguments) | 1165 | (setf (car url-callback-arguments) |
| 1168 | (nconc (list :error (list 'error 'connection-failed why | 1166 | (nconc (list :error (list 'error 'connection-failed why |