aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-06-20 09:28:09 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-06-20 09:28:09 +0000
commitf30ffef477636dc10a72eb30590a84a0218e5935 (patch)
treebaf46ee73f8c04b9f97b92456fe3347940b0a245 /lib
parent72158ad2cfa94de6aec6673ba2ef471f625f4593 (diff)
autoreferer added, switches off POST on location: following
Diffstat (limited to 'lib')
-rw-r--r--lib/highlevel.c20
-rw-r--r--lib/url.c6
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/highlevel.c b/lib/highlevel.c
index e9546142f..39a69c47e 100644
--- a/lib/highlevel.c
+++ b/lib/highlevel.c
@@ -614,6 +614,21 @@ CURLcode curl_transfer(CURL *curl)
char prot[16];
char path[URL_MAX_LENGTH];
+ if(data->bits.http_auto_referer) {
+ /* We are asked to automatically set the previous URL as the
+ referer when we get the next URL. We pick the ->url field,
+ which may or may not be 100% correct */
+
+ if(data->free_referer) {
+ /* If we already have an allocated referer, free this first */
+ free(data->referer);
+ }
+
+ data->referer = strdup(data->url);
+ data->free_referer = TRUE; /* yes, free this later */
+ data->bits.http_set_referer = TRUE; /* might have been false */
+ }
+
if(2 != sscanf(data->newurl, "%15[^:]://%" URL_MAX_LENGTH_TXT
"s", prot, path)) {
/***
@@ -681,6 +696,11 @@ CURLcode curl_transfer(CURL *curl)
data->url = data->newurl;
data->newurl = NULL; /* don't show! */
+ /* Disable both types of POSTs, since doing a second POST when
+ following isn't what anyone would want! */
+ data->bits.http_post = FALSE;
+ data->bits.http_formpost = FALSE;
+
infof(data, "Follows Location: to new URL: '%s'\n", data->url);
curl_disconnect(c_connect);
diff --git a/lib/url.c b/lib/url.c
index 6da761b22..62e81d243 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -218,6 +218,9 @@ void urlfree(struct UrlData *data, bool totally)
if(data->headerbuff)
free(data->headerbuff);
+ if(data->free_referer)
+ free(data->referer);
+
cookie_cleanup(data->cookies);
free(data);
@@ -421,6 +424,9 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
data->referer = va_arg(param, char *);
data->bits.http_set_referer = (data->referer && *data->referer)?1:0;
break;
+ case CURLOPT_AUTOREFERER:
+ data->bits.http_auto_referer = va_arg(param, long)?1:0;
+ break;
case CURLOPT_PROXY:
data->proxy = va_arg(param, char *);
data->bits.httpproxy = data->proxy?1:0;