diff --git a/CHANGES b/CHANGES index bcf0229ee..60691cfe7 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,13 @@ Changelog +Daniel Stenberg (11 Feb 2009) +- 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) + Daniel Fandrich (4 Feb 2009) - Don't add the standard /usr/lib or /usr/include paths to LDFLAGS and CPPFLAGS (respectively) when --with-ssl=/usr is used (patch based on FreeBSD). diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f761dc856..41349f0c7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -19,6 +19,7 @@ This release includes the following changes: o Improved IPv6 support when built with with c-ares >= 1.6.1 o Added CURLPROXY_HTTP_1_0 and --proxy1.0 o Added docs/libcurl/symbols-in-versions + o Added CURLINFO_CONDITION_UNMET This release includes the following bugfixes: diff --git a/docs/libcurl/curl_easy_getinfo.3 b/docs/libcurl/curl_easy_getinfo.3 index d7ece13ea..6c999cb7d 100644 --- a/docs/libcurl/curl_easy_getinfo.3 +++ b/docs/libcurl/curl_easy_getinfo.3 @@ -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 @@ -21,7 +21,7 @@ .\" * $Id$ .\" ************************************************************************** .\" -.TH curl_easy_getinfo 3 "16 Oct 2008" "libcurl 7.19.1" "libcurl Manual" +.TH curl_easy_getinfo 3 "11 Feb 2009" "libcurl 7.19.4" "libcurl Manual" .SH NAME curl_easy_getinfo - extract information from a curl handle .SH SYNOPSIS @@ -200,6 +200,12 @@ provided in a series of data in the format "name:content" where the content is for the specific named data. See also the certinfo.c example. NOTE: this option is only available in libcurl built with OpenSSL support. (Added in 7.19.1) +.IP CURLINFO_CONDITION_UNMET +Pass a pointer to a long to receive the number 1 if the condition provided in +the previous request didn't match (see \fICURLOPT_TIMECONDITION\fP). Alas, if +this returns a 1 you know that the reason you didn't get data in return is +because it didn't fulfill the condition. The long ths argument points to will +get a zero stored if the condition instead was met. (Added in 7.19.4) .SH TIMES .NF An overview of the six time values available from curl_easy_getinfo() diff --git a/docs/libcurl/curl_easy_setopt.3 b/docs/libcurl/curl_easy_setopt.3 index fc61f2804..e5e35d3d0 100644 --- a/docs/libcurl/curl_easy_setopt.3 +++ b/docs/libcurl/curl_easy_setopt.3 @@ -1326,8 +1326,10 @@ value is treated. You can set this parameter to \fICURL_TIMECOND_IFMODSINCE\fP or \fICURL_TIMECOND_IFUNMODSINCE\fP. This feature applies to HTTP and FTP. The last modification time of a file is not always known and in such instances -this feature will have no effect even if the given time condition would not have -been met. +this feature will have no effect even if the given time condition would not +have been met. \fIcurl_easy_getinfo(3)\fP with the +\fICURLINFO_CONDITION_UNMET\fP option can be used after a transfer to learn if +a zero-byte successful "transfer" was due to this condition not matching. .IP CURLOPT_TIMEVALUE Pass a long as parameter. This should be the time in seconds since 1 Jan 1970, and the time will be used in a condition as specified with diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions index 8ddaa2259..ccf996d3f 100644 --- a/docs/libcurl/symbols-in-versions +++ b/docs/libcurl/symbols-in-versions @@ -33,6 +33,7 @@ CURLFTPSSL_CCC_NONE 7.16.1 CURLFTPSSL_CCC_PASSIVE 7.16.1 CURLINFO_APPCONNECT_TIME 7.19.0 CURLINFO_CERTINFO 7.19.1 +CURLINFO_CONDITION_UNMET 7.19.4 CURLINFO_CONNECT_TIME 7.4.1 CURLINFO_CONTENT_LENGTH_DOWNLOAD 7.6.1 CURLINFO_CONTENT_LENGTH_UPLOAD 7.6.1 diff --git a/include/curl/curl.h b/include/curl/curl.h index a5d5deec7..3cbf69f7c 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -1592,9 +1592,10 @@ typedef enum { CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32, CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33, CURLINFO_CERTINFO = CURLINFO_SLIST + 34, + CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35, /* Fill in new entries below here! */ - CURLINFO_LASTONE = 34 + CURLINFO_LASTONE = 35 } CURLINFO; /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as 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 */