aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/url
diff options
context:
space:
mode:
authorLars Ingebrigtsen <[email protected]>2012-02-08 01:04:42 +0100
committerLars Ingebrigtsen <[email protected]>2012-02-08 01:04:42 +0100
commitaacaa4191173ca6d1aea3fd4ebb01ea1d5e46e7b (patch)
tree6302d500e5ab761183c51859bd856edbf2da9e72 /lisp/url
parent7c4bbb6992b443b0ce569d111fc167ad753e912c (diff)
Allow specifying whether to inhibit cookies on a per-URL basis
* url-http.el (url-http-create-request): Don't send cookies unless requested. (url-http-parse-headers): Don't store cookies unless requested. * url.el (url-retrieve): Ditto * url-queue.el (url-queue-retrieve): Take an optional `inhibit-cookies' parameter. * url-parse.el (url): Add the `use-cookies' slot to the URL struct to be able to keep track of whether to do cookies or not on a per-URL basis.
Diffstat (limited to 'lisp/url')
-rw-r--r--lisp/url/ChangeLog15
-rw-r--r--lisp/url/url-http.el9
-rw-r--r--lisp/url/url-parse.el3
-rw-r--r--lisp/url/url-queue.el11
-rw-r--r--lisp/url/url.el17
5 files changed, 42 insertions, 13 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index f4cca618b4..179148a089 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,18 @@
+2012-02-08 Lars Ingebrigtsen <[email protected]>
+
+ * url-parse.el (url): Add the `use-cookies' slot to the URL struct
+ to be able to keep track of whether to do cookies or not on a
+ per-URL basis.
+
+ * url-queue.el (url-queue-retrieve): Take an optional
+ `inhibit-cookies' parameter.
+
+ * url.el (url-retrieve): Ditto
+
+ * url-http.el (url-http-create-request): Don't send cookies unless
+ requested.
+ (url-http-parse-headers): Don't store cookies unless requested.
+
2012-02-06 Lars Ingebrigtsen <[email protected]>
* url-cache.el (url-cache-prune-cache): New function.
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index b43ed7617a..b2f93f093e 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -320,8 +320,10 @@ request.")
;; Authorization
auth
;; Cookies
- (url-cookie-generate-header-lines host real-fname
- (equal "https" (url-type url-http-target-url)))
+ (when (url-use-cookies url-http-target-url)
+ (url-cookie-generate-header-lines
+ host real-fname
+ (equal "https" (url-type url-http-target-url))))
;; If-modified-since
(if (and (not no-cache)
(member url-http-method '("GET" nil)))
@@ -498,7 +500,8 @@ should be shown to the user."
(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)
+ (when (url-use-cookies url-http-target-url)
+ (url-http-handle-cookies))
(case class
;; Classes of response codes
diff --git a/lisp/url/url-parse.el b/lisp/url/url-parse.el
index ef09622b0a..b91c85c0c3 100644
--- a/lisp/url/url-parse.el
+++ b/lisp/url/url-parse.el
@@ -35,7 +35,8 @@
(&optional type user password host portspec filename
target attributes fullness))
(:copier nil))
- type user password host portspec filename target attributes fullness silent)
+ type user password host portspec filename target attributes fullness
+ silent (use-cookies t))
(defsubst url-port (urlobj)
(or (url-portspec urlobj)
diff --git a/lisp/url/url-queue.el b/lisp/url/url-queue.el
index 976a26635c..c9c6c4fe69 100644
--- a/lisp/url/url-queue.el
+++ b/lisp/url/url-queue.el
@@ -50,10 +50,11 @@
(defstruct url-queue
url callback cbargs silentp
- buffer start-time pre-triggered)
+ buffer start-time pre-triggered
+ inhibit-cookiesp)
;;;###autoload
-(defun url-queue-retrieve (url callback &optional cbargs silent)
+(defun url-queue-retrieve (url callback &optional cbargs silent inhibit-cookies)
"Retrieve URL asynchronously and call CALLBACK with CBARGS when finished.
Like `url-retrieve' (which see for details of the arguments), but
controls the level of parallelism via the
@@ -63,7 +64,8 @@ controls the level of parallelism via the
(list (make-url-queue :url url
:callback callback
:cbargs cbargs
- :silentp silent))))
+ :silentp silent
+ :inhibit-cookiesp inhibit-cookies))))
(url-queue-setup-runners))
;; To ensure asynch behaviour, we start the required number of queue
@@ -131,7 +133,8 @@ controls the level of parallelism via the
(ignore-errors
(url-retrieve (url-queue-url job)
#'url-queue-callback-function (list job)
- (url-queue-silentp job)))))
+ (url-queue-silentp job)
+ (url-queue-inhibit-cookiesp job)))))
(defun url-queue-prune-old-entries ()
(let (dead-jobs)
diff --git a/lisp/url/url.el b/lisp/url/url.el
index 03b66b1523..933bceb2e6 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -123,7 +123,7 @@ variable in the original buffer as a forwarding pointer.")
(autoload 'url-cache-prune-cache "url-cache")
;;;###autoload
-(defun url-retrieve (url callback &optional cbargs silent)
+(defun url-retrieve (url callback &optional cbargs silent inhibit-cookies)
"Retrieve URL asynchronously and call CALLBACK with CBARGS when finished.
URL is either a string or a parsed URL.
@@ -147,7 +147,9 @@ The variables `url-request-data', `url-request-method' and
request; dynamic binding of other variables doesn't necessarily
take effect.
-If SILENT, then don't message progress reports and the like."
+If SILENT, then don't message progress reports and the like.
+If INHIBIT-COOKIES, cookies will neither be stored nor sent to
+the server."
;;; XXX: There is code in Emacs that does dynamic binding
;;; of the following variables around url-retrieve:
;;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets,
@@ -158,14 +160,18 @@ If SILENT, then don't message progress reports and the like."
;;; webmail.el; the latter should be updated. Is
;;; url-cookie-multiple-line needed anymore? The other url-cookie-*
;;; are (for now) only used in synchronous retrievals.
- (url-retrieve-internal url callback (cons nil cbargs) silent))
+ (url-retrieve-internal url callback (cons nil cbargs) silent
+ inhibit-cookies))
-(defun url-retrieve-internal (url callback cbargs &optional silent)
+(defun url-retrieve-internal (url callback cbargs &optional silent
+ inhibit-cookies)
"Internal function; external interface is `url-retrieve'.
CBARGS is what the callback will actually receive - the first item is
the list of events, as described in the docstring of `url-retrieve'.
-If SILENT, don't message progress reports and the like."
+If SILENT, don't message progress reports and the like.
+If INHIBIT-COOKIES, cookies will neither be stored nor sent to
+the server."
(url-do-setup)
(url-gc-dead-buffers)
(if (stringp url)
@@ -177,6 +183,7 @@ If SILENT, don't message progress reports and the like."
(unless (url-type url)
(error "Bad url: %s" (url-recreate-url url)))
(setf (url-silent url) silent)
+ (setf (url-use-cookies url) (not inhibit-cookies))
;; Once in a while, remove old entries from the URL cache.
(when (zerop (% url-retrieve-number-of-calls 1000))
(url-cache-prune-cache))