curl / Mailing Lists / curl-library / Single Mail

curl-library

Redirection following in progressfunction test

From: Nicolas Roeser <nicolas.roeser_at_uni-ulm.de>
Date: Sun, 7 Apr 2019 22:24:38 +0200

It seems that if an xferfunction is used *and* CURLOPT_FOLLOWLOCATION is
enabled, the redirection is not taken after the 'Location:' header field
has been seen, but after the redirect*ing* document has been read. This
behavior is not in line with libcurl returning the redirected-*to*
document (instead of the redirect*ing* one or everything) on redirects.

The latter behavior is fine (see also
<https://curl.haxx.se/mail/lib-2014-08/0171.html>), but the former is
not.

---
 docs/examples/progressfunc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/examples/progressfunc.c b/docs/examples/progressfunc.c
index 86ad0d9ca..8bb17d886 100644
--- a/docs/examples/progressfunc.c
+++ b/docs/examples/progressfunc.c
@@ -42,7 +42,7 @@
 #define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL     3
 #endif
 
-#define STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES         6000
+#define STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES         5000
 
 struct myprogress {
   TIMETYPE lastruntime; /* type depends on version, see above */
@@ -108,7 +108,7 @@ int main(void)
     prog.lastruntime = 0;
     prog.curl = curl;
 
-    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:8102/reallylong");
 
 #if LIBCURL_VERSION_NUM >= 0x072000
     /* xferinfo was introduced in 7.32.0, no earlier libcurl versions will
@@ -132,6 +132,8 @@ int main(void)
 #endif
 
     curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    //curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
     res = curl_easy_perform(curl);
 
     if(res != CURLE_OK)
-- 
2.21.0
--jI8keyz6grp/JLjh
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLQpVbnN1YnNjcmliZTogaHR0cHM6Ly9jb29sLmhheHguc2UvbGlzdC9saXN0aW5m
by9jdXJsLWxpYnJhcnkKRXRpcXVldHRlOiAgIGh0dHBzOi8vY3VybC5oYXh4LnNlL21haWwvZXRp
cXVldHRlLmh0bWw=
--jI8keyz6grp/JLjh--
Received on 2001-09-17