[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/with-url be65731 7/8: Allow specifying that redire
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] scratch/with-url be65731 7/8: Allow specifying that redirects should not be followed |
Date: |
Sun, 22 Jan 2017 00:29:33 +0000 (UTC) |
branch: scratch/with-url
commit be65731663bfe738b4ca843b96a7eceabc79a82f
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Allow specifying that redirects should not be followed
---
lisp/url/with-url.el | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/lisp/url/with-url.el b/lisp/url/with-url.el
index a656618..a50d5da 100644
--- a/lisp/url/with-url.el
+++ b/lisp/url/with-url.el
@@ -40,7 +40,7 @@
callback redirect-times
url parsed-url process
response-size start-time last-read-time timer
- finished)
+ finished follow-redirects)
(defvar with-url-debug nil
"If non-nil, record all actions in the \"*url-debug*\" buffer.")
@@ -54,6 +54,7 @@
(verbose 5)
(cookies t)
(cache t)
+ (follow-redirects t)
debug
headers
ignore-errors
@@ -104,6 +105,10 @@ buffer. This buffer may grow very large.
If non-nil, the body will not be executed if the contents
specified by the URL could not be fetched.
+:follow-redirects BOOL
+If non-nil (which is the default), follow HTTP redirects until
+the final document is reached.
+
:cookies t/read/write/nil
If nil, cookies will neither be sent nor stored. If `read',
cookies will be recorded, but not sent. If `write', cookies will
@@ -167,6 +172,7 @@ and `base64'."
:data-encoding ,data-encoding
:start-time (current-time)
:last-read-time (current-time)
+ :follow-redirects ,follow-redirects
:redirect-times 0)))
,(if wait
`(progn
@@ -506,9 +512,13 @@ If given, return the value in BUFFER instead."
;; Redirects.
((<= 300 code 399)
(cl-incf (url-request-redirect-times req))
- (if (> (url-request-redirect-times req) 10)
- (with-url--callback process '(500 "Too many redirections"))
- (with-url--redirect process (url-header 'location))))
+ (cond
+ ((not (url-request-follow-redirects req))
+ (with-url--callback process '(200 "Redirect not followed")))
+ ((> (url-request-redirect-times req) 10)
+ (with-url--callback process '(500 "Too many redirections")))
+ (t
+ (with-url--redirect process (url-header 'location)))))
(t
(with-url--callback process)))))
- [Emacs-diffs] scratch/with-url updated (f74e07b -> 9d2e1e3), Lars Ingebrigtsen, 2017/01/21
- [Emacs-diffs] scratch/with-url dbc317f 2/8: Fix syntax error in with-url rework, Lars Ingebrigtsen, 2017/01/21
- [Emacs-diffs] scratch/with-url 5bd8812 4/8: Make :wait case actually work., Lars Ingebrigtsen, 2017/01/21
- [Emacs-diffs] scratch/with-url 495cb41 1/8: Handle the case where the peer drops connection with no Content-Length, Lars Ingebrigtsen, 2017/01/21
- [Emacs-diffs] scratch/with-url 3ee6d63 3/8: Rework for with-url, Lars Ingebrigtsen, 2017/01/21
- [Emacs-diffs] scratch/with-url 724b285 6/8: Always kill the buffer, even when ignoring errors, Lars Ingebrigtsen, 2017/01/21
- [Emacs-diffs] scratch/with-url be65731 7/8: Allow specifying that redirects should not be followed,
Lars Ingebrigtsen <=
- [Emacs-diffs] scratch/with-url 8ff9bd5 5/8: Remove unused parameter, Lars Ingebrigtsen, 2017/01/21
- [Emacs-diffs] scratch/with-url 9d2e1e3 8/8: Increase timeouts not that progress is more ensured, Lars Ingebrigtsen, 2017/01/21