diff options
| author | Magnus Henoch | 2007-01-14 23:17:08 +0000 |
|---|---|---|
| committer | Magnus Henoch | 2007-01-14 23:17:08 +0000 |
| commit | 62bfb5bb9883f79fca3950ea906184233ab90c63 (patch) | |
| tree | 00509c18189ee2aef4a68f44b15447f9bf9e0951 | |
| parent | c45b3be32d410984a9767c876024b348442333c5 (diff) | |
| download | emacs-62bfb5bb9883f79fca3950ea906184233ab90c63.tar.gz emacs-62bfb5bb9883f79fca3950ea906184233ab90c63.zip | |
(url-http-proxy): New variable.
(url-http-create-request): Use it. Don't use `url-proxy-object'.
(url-http): Treat `url' argument as resource to download, and
dynamic variable `url-using-proxy' as proxy to use. Set
`url-current-object' to actual URL, and `url-http-proxy' to proxy
used.
(url-http-handle-cookies): Assume that `url-current-object' does
not point to the proxy used.
(url-http-async-sentinel): Adapt error message.
| -rw-r--r-- | lisp/url/url-http.el | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 309be690408..cbfea2a1187 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | (eval-when-compile (require 'cl)) | 29 | (eval-when-compile (require 'cl)) |
| 30 | (defvar url-http-extra-headers) | 30 | (defvar url-http-extra-headers) |
| 31 | (defvar url-http-target-url) | 31 | (defvar url-http-target-url) |
| 32 | (defvar url-http-proxy) | ||
| 32 | (require 'url-gw) | 33 | (require 'url-gw) |
| 33 | (require 'url-util) | 34 | (require 'url-util) |
| 34 | (require 'url-parse) | 35 | (require 'url-parse) |
| @@ -154,11 +155,10 @@ request.") | |||
| 154 | (declare (special proxy-info | 155 | (declare (special proxy-info |
| 155 | url-http-method url-http-data | 156 | url-http-method url-http-data |
| 156 | url-http-extra-headers)) | 157 | url-http-extra-headers)) |
| 157 | (url-http-debug "url-proxy-object is %s\n" url-proxy-object) | ||
| 158 | (let* ((extra-headers) | 158 | (let* ((extra-headers) |
| 159 | (request nil) | 159 | (request nil) |
| 160 | (no-cache (cdr-safe (assoc "Pragma" url-http-extra-headers))) | 160 | (no-cache (cdr-safe (assoc "Pragma" url-http-extra-headers))) |
| 161 | (using-proxy (not (eq url-current-object url-http-target-url))) | 161 | (using-proxy url-http-proxy) |
| 162 | (proxy-auth (if (or (cdr-safe (assoc "Proxy-Authorization" | 162 | (proxy-auth (if (or (cdr-safe (assoc "Proxy-Authorization" |
| 163 | url-http-extra-headers)) | 163 | url-http-extra-headers)) |
| 164 | (not using-proxy)) | 164 | (not using-proxy)) |
| @@ -379,8 +379,7 @@ This allows us to use `mail-fetch-field', etc." | |||
| 379 | The buffer must already be narrowed to the headers, so `mail-fetch-field' will | 379 | The buffer must already be narrowed to the headers, so `mail-fetch-field' will |
| 380 | work correctly." | 380 | work correctly." |
| 381 | (let ((cookies (mail-fetch-field "Set-Cookie" nil nil t)) | 381 | (let ((cookies (mail-fetch-field "Set-Cookie" nil nil t)) |
| 382 | (cookies2 (mail-fetch-field "Set-Cookie2" nil nil t)) | 382 | (cookies2 (mail-fetch-field "Set-Cookie2" nil nil t))) |
| 383 | (url-current-object url-http-target-url)) | ||
| 384 | (and cookies (url-http-debug "Found %d Set-Cookie headers" (length cookies))) | 383 | (and cookies (url-http-debug "Found %d Set-Cookie headers" (length cookies))) |
| 385 | (and cookies2 (url-http-debug "Found %d Set-Cookie2 headers" (length cookies2))) | 384 | (and cookies2 (url-http-debug "Found %d Set-Cookie2 headers" (length cookies2))) |
| 386 | (while cookies | 385 | (while cookies |
| @@ -1087,18 +1086,16 @@ CBARGS as the arguments." | |||
| 1087 | url-http-chunked-start | 1086 | url-http-chunked-start |
| 1088 | url-http-chunked-counter | 1087 | url-http-chunked-counter |
| 1089 | url-http-process)) | 1088 | url-http-process)) |
| 1090 | (let ((connection (url-http-find-free-connection (url-host url) | 1089 | (let* ((host (url-host (or url-using-proxy url))) |
| 1091 | (url-port url))) | 1090 | (port (url-port (or url-using-proxy url))) |
| 1092 | (buffer (generate-new-buffer (format " *http %s:%d*" | 1091 | (connection (url-http-find-free-connection host port)) |
| 1093 | (url-host url) | 1092 | (buffer (generate-new-buffer (format " *http %s:%d*" host port)))) |
| 1094 | (url-port url))))) | ||
| 1095 | (if (not connection) | 1093 | (if (not connection) |
| 1096 | ;; Failed to open the connection for some reason | 1094 | ;; Failed to open the connection for some reason |
| 1097 | (progn | 1095 | (progn |
| 1098 | (kill-buffer buffer) | 1096 | (kill-buffer buffer) |
| 1099 | (setq buffer nil) | 1097 | (setq buffer nil) |
| 1100 | (error "Could not create connection to %s:%d" (url-host url) | 1098 | (error "Could not create connection to %s:%d" host port)) |
| 1101 | (url-port url))) | ||
| 1102 | (with-current-buffer buffer | 1099 | (with-current-buffer buffer |
| 1103 | (mm-disable-multibyte) | 1100 | (mm-disable-multibyte) |
| 1104 | (setq url-current-object url | 1101 | (setq url-current-object url |
| @@ -1120,7 +1117,8 @@ CBARGS as the arguments." | |||
| 1120 | url-http-method | 1117 | url-http-method |
| 1121 | url-http-extra-headers | 1118 | url-http-extra-headers |
| 1122 | url-http-data | 1119 | url-http-data |
| 1123 | url-http-target-url)) | 1120 | url-http-target-url |
| 1121 | url-http-proxy)) | ||
| 1124 | (set (make-local-variable var) nil)) | 1122 | (set (make-local-variable var) nil)) |
| 1125 | 1123 | ||
| 1126 | (setq url-http-method (or url-request-method "GET") | 1124 | (setq url-http-method (or url-request-method "GET") |
| @@ -1133,8 +1131,8 @@ CBARGS as the arguments." | |||
| 1133 | url-callback-function callback | 1131 | url-callback-function callback |
| 1134 | url-callback-arguments cbargs | 1132 | url-callback-arguments cbargs |
| 1135 | url-http-after-change-function 'url-http-wait-for-headers-change-function | 1133 | url-http-after-change-function 'url-http-wait-for-headers-change-function |
| 1136 | url-http-target-url (or url-proxy-object | 1134 | url-http-target-url url-current-object |
| 1137 | url-current-object)) | 1135 | url-http-proxy url-using-proxy) |
| 1138 | 1136 | ||
| 1139 | (set-process-buffer connection buffer) | 1137 | (set-process-buffer connection buffer) |
| 1140 | (set-process-filter connection 'url-http-generic-filter) | 1138 | (set-process-filter connection 'url-http-generic-filter) |
| @@ -1145,8 +1143,7 @@ CBARGS as the arguments." | |||
| 1145 | (set-process-sentinel connection 'url-http-async-sentinel)) | 1143 | (set-process-sentinel connection 'url-http-async-sentinel)) |
| 1146 | ((eq status 'failed) | 1144 | ((eq status 'failed) |
| 1147 | ;; Asynchronous connection failed | 1145 | ;; Asynchronous connection failed |
| 1148 | (error "Could not create connection to %s:%d" (url-host url) | 1146 | (error "Could not create connection to %s:%d" host port)) |
| 1149 | (url-port url))) | ||
| 1150 | (t | 1147 | (t |
| 1151 | (set-process-sentinel connection 'url-http-end-of-document-sentinel) | 1148 | (set-process-sentinel connection 'url-http-end-of-document-sentinel) |
| 1152 | (process-send-string connection (url-http-create-request))))))) | 1149 | (process-send-string connection (url-http-create-request))))))) |
| @@ -1164,8 +1161,8 @@ CBARGS as the arguments." | |||
| 1164 | (t | 1161 | (t |
| 1165 | (setf (car url-callback-arguments) | 1162 | (setf (car url-callback-arguments) |
| 1166 | (nconc (list :error (list 'error 'connection-failed why | 1163 | (nconc (list :error (list 'error 'connection-failed why |
| 1167 | :host (url-host url-current-object) | 1164 | :host (url-host (or url-http-proxy url-current-object)) |
| 1168 | :service (url-port url-current-object))) | 1165 | :service (url-port (or url-http-proxy url-current-object)))) |
| 1169 | (car url-callback-arguments))) | 1166 | (car url-callback-arguments))) |
| 1170 | (url-http-activate-callback))))) | 1167 | (url-http-activate-callback))))) |
| 1171 | 1168 | ||