aboutsummaryrefslogtreecommitdiff
path: root/src/writeout.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-04-30 21:20:08 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-04-30 21:20:08 +0000
commit852989856d3802a9e7bd2f1e368302d92ddf66e2 (patch)
treec26ddf2fbf798b3939f0867bff7b90dfdcde0148 /src/writeout.c
parent7dfdbf8fbebab9af95e19c5ff8af3073218e4a4f (diff)
- To make it easier for applications that want lots of magic stuff done on
redirections and thus cannot use CURLOPT_FOLLOWLOCATION easily, we now introduce the new CURLINFO_REDIRECT_URL option that lets applications extract the URL libcurl would've redirected to if it had been told to. This then enables the application to continue to that URL as it thinks is suitable, without having to re-implement the magic of creating the new URL from the Location: header etc. Test 1029 verifies it.
Diffstat (limited to 'src/writeout.c')
-rw-r--r--src/writeout.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/writeout.c b/src/writeout.c
index b45b7cba4..2a0e37af2 100644
--- a/src/writeout.c
+++ b/src/writeout.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -61,6 +61,7 @@ typedef enum {
VAR_REDIRECT_TIME,
VAR_REDIRECT_COUNT,
VAR_FTP_ENTRY_PATH,
+ VAR_REDIRECT_URL,
VAR_NUM_OF_VARS /* must be the last */
} replaceid;
@@ -73,6 +74,7 @@ struct variable {
static const struct variable replacements[]={
{"url_effective", VAR_EFFECTIVE_URL},
{"http_code", VAR_HTTP_CODE},
+ {"response_code", VAR_HTTP_CODE},
{"http_connect", VAR_HTTP_CODE_PROXY},
{"time_total", VAR_TOTAL_TIME},
{"time_namelookup", VAR_NAMELOOKUP_TIME},
@@ -90,6 +92,7 @@ static const struct variable replacements[]={
{"time_redirect", VAR_REDIRECT_TIME},
{"num_redirects", VAR_REDIRECT_COUNT},
{"ftp_entry_path", VAR_FTP_ENTRY_PATH},
+ {"redirect_url", VAR_REDIRECT_URL},
{NULL, VAR_NONE}
};
@@ -222,6 +225,12 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
&& stringp)
fputs(stringp, stream);
break;
+ case VAR_REDIRECT_URL:
+ if((CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &stringp))
+ && stringp)
+ fputs(stringp, stream);
+ break;
default:
break;
}