aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Henoch2006-11-26 13:22:52 +0000
committerMagnus Henoch2006-11-26 13:22:52 +0000
commitb9b172ace737cc3d3df1af5b90e5e5a6b277bd6a (patch)
tree64ffa676f4e4d182fe41d3c0973cb91eac31e2bf
parent57babe17161b695f9e23d6d206c1b7c8f40de72a (diff)
downloademacs-b9b172ace737cc3d3df1af5b90e5e5a6b277bd6a.tar.gz
emacs-b9b172ace737cc3d3df1af5b90e5e5a6b277bd6a.zip
(url-http): Define url-http-response-version.
(url-http-parse-response): Set it. (url-http-parse-headers): Use it to determine keep-alive behavior.
-rw-r--r--lisp/url/ChangeLog3
-rw-r--r--lisp/url/url-http.el25
2 files changed, 24 insertions, 4 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 2175a4e53d0..c50dcf52897 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -2,6 +2,9 @@
2 2
3 * url-http.el (url-http-wait-for-headers-change-function): Use 3 * url-http.el (url-http-wait-for-headers-change-function): Use
4 `when' instead of `if' when possible. 4 `when' instead of `if' when possible.
5 (url-http): Define url-http-response-version.
6 (url-http-parse-response): Set it.
7 (url-http-parse-headers): Use it to determine keep-alive behavior.
5 8
62006-11-23 Diane Murray <disumu@x3y2z1.net> 92006-11-23 Diane Murray <disumu@x3y2z1.net>
7 10
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 2fb608d2b92..ad556c30a07 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -358,14 +358,19 @@ This allows us to use `mail-fetch-field', etc."
358 358
359(defun url-http-parse-response () 359(defun url-http-parse-response ()
360 "Parse just the response code." 360 "Parse just the response code."
361 (declare (special url-http-end-of-headers url-http-response-status)) 361 (declare (special url-http-end-of-headers url-http-response-status
362 url-http-response-version))
362 (if (not url-http-end-of-headers) 363 (if (not url-http-end-of-headers)
363 (error "Trying to parse HTTP response code in odd buffer: %s" (buffer-name))) 364 (error "Trying to parse HTTP response code in odd buffer: %s" (buffer-name)))
364 (url-http-debug "url-http-parse-response called in (%s)" (buffer-name)) 365 (url-http-debug "url-http-parse-response called in (%s)" (buffer-name))
365 (goto-char (point-min)) 366 (goto-char (point-min))
366 (skip-chars-forward " \t\n") ; Skip any blank crap 367 (skip-chars-forward " \t\n") ; Skip any blank crap
367 (skip-chars-forward "HTTP/") ; Skip HTTP Version 368 (skip-chars-forward "HTTP/") ; Skip HTTP Version
368 (read (current-buffer)) 369 (setq url-http-response-version
370 (buffer-substring (point)
371 (progn
372 (skip-chars-forward "[0-9].")
373 (point))))
369 (setq url-http-response-status (read (current-buffer)))) 374 (setq url-http-response-status (read (current-buffer))))
370 375
371(defun url-http-handle-cookies () 376(defun url-http-handle-cookies ()
@@ -391,6 +396,7 @@ should be shown to the user."
391 ;; The comments after each status code handled are taken from RFC 396 ;; The comments after each status code handled are taken from RFC
392 ;; 2616 (HTTP/1.1) 397 ;; 2616 (HTTP/1.1)
393 (declare (special url-http-end-of-headers url-http-response-status 398 (declare (special url-http-end-of-headers url-http-response-status
399 url-http-response-version
394 url-http-method url-http-data url-http-process 400 url-http-method url-http-data url-http-process
395 url-callback-function url-callback-arguments)) 401 url-callback-function url-callback-arguments))
396 402
@@ -407,9 +413,19 @@ should be shown to the user."
407 (mail-narrow-to-head) 413 (mail-narrow-to-head)
408 ;;(narrow-to-region (point-min) url-http-end-of-headers) 414 ;;(narrow-to-region (point-min) url-http-end-of-headers)
409 (let ((connection (mail-fetch-field "Connection"))) 415 (let ((connection (mail-fetch-field "Connection")))
410 (if (and connection 416 ;; In HTTP 1.0, keep the connection only if there is a
411 (string= (downcase connection) "close")) 417 ;; "Connection: keep-alive" header.
418 ;; In HTTP 1.1 (and greater), keep the connection unless there is a
419 ;; "Connection: close" header
420 (cond
421 ((string= url-http-response-version "1.0")
422 (unless (and connection
423 (string= (downcase connection) "keep-alive"))
412 (delete-process url-http-process))) 424 (delete-process url-http-process)))
425 (t
426 (when (and connection
427 (string= (downcase connection) "close"))
428 (delete-process url-http-process)))))
413 (let ((class nil) 429 (let ((class nil)
414 (success nil)) 430 (success nil))
415 (setq class (/ url-http-response-status 100)) 431 (setq class (/ url-http-response-status 100))
@@ -1093,6 +1109,7 @@ CBARGS as the arguments."
1093 url-http-content-length 1109 url-http-content-length
1094 url-http-transfer-encoding 1110 url-http-transfer-encoding
1095 url-http-after-change-function 1111 url-http-after-change-function
1112 url-http-response-version
1096 url-http-response-status 1113 url-http-response-status
1097 url-http-chunked-length 1114 url-http-chunked-length
1098 url-http-chunked-counter 1115 url-http-chunked-counter