From 002cf105c6779ecf66acb36ba86aa415b8b98b09 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 11 Feb 2009 21:47:14 +0000 Subject: - CURLINFO_CONDITION_UNMET was added to allow an application to get to know if the condition in the previous request was unmet. This is typically a time condition set with CURLOPT_TIMECONDITION and was previously not possible to reliably figure out. From bug report #2565128 (http://curl.haxx.se/bug/view.cgi?id=2565128) --- lib/ftp.c | 2 ++ lib/getinfo.c | 6 +++++- lib/transfer.c | 6 +++++- lib/urldata.h | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/ftp.c b/lib/ftp.c index 3cc259d69..f76868f0d 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -2045,6 +2045,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn, if(data->info.filetime <= data->set.timevalue) { infof(data, "The requested document is not new enough\n"); ftp->transfer = FTPTRANSFER_NONE; /* mark this to not transfer data */ + data->info.timecond = TRUE; state(conn, FTP_STOP); return CURLE_OK; } @@ -2053,6 +2054,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn, if(data->info.filetime > data->set.timevalue) { infof(data, "The requested document is not old enough\n"); ftp->transfer = FTPTRANSFER_NONE; /* mark this to not transfer data */ + data->info.timecond = TRUE; state(conn, FTP_STOP); return CURLE_OK; } diff --git a/lib/getinfo.c b/lib/getinfo.c index c8841637e..bc387c960 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -228,6 +228,10 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) ptr.to_certinfo = &data->info.certs; *param_slistp = ptr.to_slist; break; + case CURLINFO_CONDITION_UNMET: + /* return if the condition prevented the document to get transfered */ + *param_longp = data->info.timecond; + break; default: return CURLE_BAD_FUNCTION_ARGUMENT; } diff --git a/lib/transfer.c b/lib/transfer.c index 43a9cc294..17e361366 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -497,6 +497,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, infof(data, "The requested document is not new enough\n"); *done = TRUE; + data->info.timecond = TRUE; return CURLE_OK; } break; @@ -505,6 +506,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, infof(data, "The requested document is not old enough\n"); *done = TRUE; + data->info.timecond = TRUE; return CURLE_OK; } break; @@ -1107,6 +1109,8 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, * MUST NOT contain a message-body, and thus is always * terminated by the first empty line after the header * fields. */ + if(data->set.timecondition) + data->info.timecond = TRUE; k->size=0; k->maxdownload=0; k->ignorecl = TRUE; /* ignore Content-Length headers */ diff --git a/lib/urldata.h b/lib/urldata.h index 530480ddb..be3f06191 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1063,6 +1063,8 @@ struct PureInfo { was unretrievable. We cannot have this of type time_t, since time_t is unsigned on several platforms such as OpenVMS. */ + bool timecond; /* set to TRUE if the time condition didn't match, which + thus made the document NOT get fetched */ long header_size; /* size of read header(s) in bytes */ long request_size; /* the amount of bytes sent in the request(s) */ long proxyauthavail; /* what proxy auth types were announced */ -- cgit v1.2.3