- CURLINFO_CONDITION_UNMET was added to allow an application to get to know if
authorDaniel Stenberg <daniel@haxx.se>
Wed, 11 Feb 2009 21:47:14 +0000 (21:47 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 11 Feb 2009 21:47:14 +0000 (21:47 +0000)
  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)

CHANGES
RELEASE-NOTES
docs/libcurl/curl_easy_getinfo.3
docs/libcurl/curl_easy_setopt.3
docs/libcurl/symbols-in-versions
include/curl/curl.h
lib/ftp.c
lib/getinfo.c
lib/transfer.c
lib/urldata.h

diff --git a/CHANGES b/CHANGES
index bcf0229..60691cf 100644 (file)
--- 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).
index f761dc8..41349f0 100644 (file)
@@ -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:
 
index d7ece13..6c999cb 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2009, 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
@@ -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()
index fc61f28..e5e35d3 100644 (file)
@@ -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
index 8ddaa22..ccf996d 100644 (file)
@@ -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
index a5d5dee..3cbf69f 100644 (file)
@@ -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
index 3cc259d..f76868f 100644 (file)
--- 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;
         }
index c884163..bc387c9 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2009, 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
@@ -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;
   }
index 43a9cc2..17e3613 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2009, 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
@@ -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 */
index 530480d..be3f061 100644 (file)
@@ -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 */